Table of Contents generated with DocToc
This repository contains a TODO API built with FastAPI and SQLAlchemy, focusing on asynchronous programming for efficient performance.
docker run --name fastapi_todo_async -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=fastapi_todo_async -e MYSQL_USER=fastapi_todo_async -e MYSQL_PASSWORD=fastapi_todo_async -e MYSQL_DATABASE=fastapi_todo_async mysql:latest
- Asynchronous: Utilizes FastAPI and SQLAlchemy's async capabilities for non-blocking operations.
- CRUD Operations: Implements Create, Read, Update, and Delete operations for TODO items.
- Error Handling: Uses HTTPException to manage error responses and validation using Pydantic schemas.
- API Documentation: Provides Swagger UI and ReDoc for interactive API documentation.
- Python 3.7+
- FastAPI
- SQLAlchemy
-
Clone the repository:
git clone https://github.com/ktechhub/fastapi_todo_async.git cd fastapi_todo_async
-
Create a virtual environment:
python -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Copy and update .env file
cp .env.example .env
-
Set up the database configuration in
app/core/config.py
. -
Run the FastAPI application:
uvicorn app.main:app --reload
Visit
http://localhost:8000/docs
for Swagger UI orhttp://localhost:8000/redoc
for ReDoc.
- POST
/todos/
: Create a new TODO item. - GET
/todos/
: Get all TODO items. - GET
/todos/{id}/
: Get a TODO item by ID. - PUT
/todos/{id}/
: Update a TODO item by ID. - DELETE
/todos/{id}/
: Delete a TODO item by ID.
- Modify
app/core/config.py
to configure database settings (DATABASE_URL
, etc.).
This project is licensed under the MIT License - see the LICENSE file for details.