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)
- Host: GitHub
- URL: https://github.com/joeldeondsouza/py_backend
- Owner: JoelDeonDsouza
- Created: 2024-04-17T12:07:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-17T12:16:06.000Z (about 2 years ago)
- Last Synced: 2025-04-08T14:52:32.984Z (about 1 year ago)
- Topics: flask, flask-cors, python, python3, sqlalchemy, sqlalchemy-database
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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'