An open API service indexing awesome lists of open source software.

https://github.com/joeldeondsouza/py_backend

Simple Backend for user management with Flask(Python)
https://github.com/joeldeondsouza/py_backend

flask flask-cors python python3 sqlalchemy sqlalchemy-database

Last synced: about 1 month ago
JSON representation

Simple Backend for user management with Flask(Python)

Awesome Lists containing this project

README

          

# User Management API

This Flask application provides a simple API for managing users including creating, retrieving, updating, and deleting user records in a database.

## Installation

```bash
https://github.com/JoelDeonDsouza/PY_Backend.git
```

1. Clone this repository to your local machine.
2. Install the required dependencies by running `pip install -r requirements.txt`.
3. Set up the database configuration in the `config.py` file.
4. Run the application using `python main.py || python3 main.py`.

## Usage

### Get Users
- **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.

### Create User
- **Endpoint:** `/create_user`
- **Method:** `POST`
- **Description:** Creates a new user record in the database.
- **Request Body:** Requires a JSON object with `name` and `email` fields.
- **Response:** Returns a success message if the user is created successfully.

### Update User
- **Endpoint:** `/update_user/`
- **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` and `email` fields to be updated.
- **Response:** Returns a success message if the user is updated successfully.

### Delete User
- **Endpoint:** `/delete_user/`
- **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.

## Running the Application

To run the application, execute `python main.py || python3 main.py` in your terminal. By default, the application runs in debug mode.

## Note

Make sure to set up the database configuration in the `config.py` file before running the application.

```python
# config.py

app.config['SQLALCHEMY_DATABASE_URI'] = 'your_database_uri_here'