Automated Action cdd4aec842 Build simple todo app with FastAPI and SQLite
- Created FastAPI application with CRUD operations for todos
- Implemented SQLite database with SQLAlchemy ORM
- Added Alembic for database migrations
- Set up CORS middleware for all origins
- Added health check endpoint at /health
- Created comprehensive API documentation
- Formatted code with Ruff linter
- Updated README with project information

Features:
- Create, read, update, delete todos
- Pagination support for listing todos
- Auto-generated OpenAPI documentation at /docs
- Health monitoring endpoint
2025-06-19 21:46:14 +00:00

40 lines
884 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.routers import todos
from app.db.session import engine
from app.db.base import Base
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Todo App API",
description="A simple Todo application API built with FastAPI",
version="1.0.0",
openapi_url="/openapi.json",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(todos.router)
@app.get("/")
def read_root():
return {
"title": "Todo App API",
"description": "A simple Todo application API built with FastAPI",
"documentation": "/docs",
"health_check": "/health",
}
@app.get("/health")
def health_check():
return {"status": "healthy", "service": "todo-api"}