This project is a simple Todo API built with Flask, following a clean architecture approach. It includes endpoints to create, read, update, and delete todo items:
GET /api/todo/<int:todo_id>: Retrieve a todo item by ID.
POST /api/todo: Create a new todo item.
PUT /api/todo/<int:todo_id>: Update an existing todo item.
DELETE /api/todo/<int:todo_id>: Delete a todo item by ID.
- Docker
- Python 3.7+
- pip (Python package installer)
-
Clone the repository:
git clone [email protected]:manuel-io/sample-python-flask-api.git cd sample-python-flask-api
-
Create and activate a virtual environment:
python -m venv venv # Activate env on MacOS/Linux source venv/bin/activate # On Windows use venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Set up environment variables:
# For local development FLASK_APP=run.py FLASK_ENV=development DATABASE_URL=sqlite:///database.db API_URL=http://127.0.0.1:5000/api
python run.pygunicorn --bind 0.0.0.0:8000 wsgi:appThe API will be available at http://127.0.0.1:8000/api and Swagger UI will be available at http://127.0.0.1:8000/api/swagger.
docker build -t todo-api .docker run -d -p 8000:8000 --name todo-api-container todo-apiThe API will be available at http://127.0.0.1:8000/api and Swagger UI will be available at http://127.0.0.1:8000/api/swagger.
To run unit tests, use the following command:
python -m unittest discover -s tests/unitTo run integration tests, use the following command:
python -m unittest discover -s tests/integrationThis project is licensed under the MIT License. See the LICENSE file for details.