This Flask application provides a simple API for managing users including creating, retrieving, updating, and deleting user records in a database.
https://github.com/JoelDeonDsouza/PY_Backend.git
- Clone this repository to your local machine.
- Install the required dependencies by running
pip install -r requirements.txt
. - Set up the database configuration in the
config.py
file. - Run the application using
python main.py || python3 main.py
.
- Endpoint:
/users
- Method:
GET
- Description: Retrieves a list of all users stored in the database.
- Response: Returns a JSON object containing the list of users.
- Endpoint:
/create_user
- Method:
POST
- Description: Creates a new user record in the database.
- Request Body: Requires a JSON object with
name
andemail
fields. - Response: Returns a success message if the user is created successfully.
- Endpoint:
/update_user/<user_id>
- Method:
PATCH
- Description: Updates an existing user record in the database.
- Parameters: Requires the
user_id
of the user to be updated. - Request Body: Accepts a JSON object with optional
name
andemail
fields to be updated. - Response: Returns a success message if the user is updated successfully.
- Endpoint:
/delete_user/<user_id>
- Method:
DELETE
- Description: Deletes an existing user record from the database.
- Parameters: Requires the
user_id
of the user to be deleted. - Response: Returns a success message if the user is deleted successfully.
To run the application, execute python main.py || python3 main.py
in your terminal. By default, the application runs in debug mode.
Make sure to set up the database configuration in the config.py
file before running the application.
# config.py
app.config['SQLALCHEMY_DATABASE_URI'] = 'your_database_uri_here'