Code Monkey home page Code Monkey logo

software-engineering-intern-assessment's Introduction

Software-Engineering-Intern-Assessment

Introduction

This project is a simple FastAPI web application that provides a basic login functionality using a MySQL database. It allows users to enter their username and password and checks if the provided credentials match any entry in the MySQL database. If the credentials are valid, it returns a "Login successful" message; otherwise, it raises an HTTP 401 "Invalid credentials" error.

Project Setup

To set up and run this project, follow the steps below:

Pre-requisites

Python: Make sure you have Python installed on your system. This project requires Python 3.6 or higher. MySQL: You need a running MySQL server. Ensure that you have the necessary credentials (username and password) to connect to the MySQL server. If you don't have MySQL installed, you can download and install it from the official website: https://dev.mysql.com/downloads/installer/

Installation

  1. Clone this repository to your local machine:
git clone <repository-url>
cd <repository-folder>
  1. Create a virtual environment:
python -m venv venv
  1. Activate the virtual environment: On Windows:
venv\Scripts\activate

On macOS and Linux:

source venv/bin/activate
  1. Install the required Python packages:
pip install -r requirements.txt

Database Setup

The application creates a test table 'users' with some sample data to demonstrate the login functionality.

Running the Application

To run the FastAPI application, execute the following command:

uvicorn app:app --reload

The '--reload' option enables automatic code reloading during development, so you don't have to restart the server after each code change.

Accessing the Application

Once the application is running, you can access it in your web browser by navigating to 'http://127.0.0.1:8000/' The login page will be displayed.

Login Functionality

  • Enter the username and password in the respective input fields.
  • Click on the "Login" button.
  • The form data will be sent to the server using a POST request to /login/.
  • If the provided credentials are valid, you will see a "Login successful" message.
  • If the credentials are invalid, you will see an "Invalid credentials" message.

Notes

  1. This is a simple demonstration of login functionality.
  2. The database connection details are hardcoded in the main.py file for demonstration purposes.
  3. The 'mysql.connector' library is used in this project for MySQL database connection.

software-engineering-intern-assessment's People

Contributors

kishwanth21 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.