This is a Python-based RESTful API for managing users, built using Flask and SQLAlchemy.
- Create, Read, Update, and Delete (CRUD) operations for users.
- Modular structure with clear separation of concerns.
- Proper error handling with HTTP status codes.
- Unit tests to ensure functionality.
Follow these steps to set up and run the application:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateInstall the required Python packages:
pip install -r requirements.txtStart the Flask server:
python app.pyThe server will run at http://127.0.0.1:5000.
Execute the unit tests to verify functionality:
python -m unittest discover tests- POST
/api/users - Request Body:
{ "name": "John Doe", "email": "john@example.com" }
- GET
/api/users
- GET
/api/users/<id>
- PUT
/api/users/<id> - Request Body:
{ "name": "Jane Doe", "email": "jane@example.com" }
- DELETE
/api/users/<id>
After running the application, here’s what the responses might look like:
-
GET /api/users:
[]
-
POST /api/users:
{ "id": 1, "name": "John Doe", "email": "john@example.com" }