Automated Action ef0bc51fbb Create simple FastAPI todo application
- Set up project structure with proper directory layout
- Implemented SQLite database with SQLAlchemy ORM
- Created Todo model with CRUD operations
- Added Alembic for database migrations
- Implemented RESTful API endpoints for todos
- Added health check endpoint
- Configured CORS for all origins
- Created comprehensive documentation
- Added linting with Ruff
2025-06-17 06:40:03 +00:00

38 lines
930 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.routes import todos_router, health_router
from app.db.session import engine
from app.db.base import Base
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Todo API",
description="A simple Todo application API built with FastAPI",
version="1.0.0",
openapi_url="/openapi.json"
)
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(todos_router, prefix="/api/v1")
app.include_router(health_router)
@app.get("/")
def root():
return {
"title": "Todo API",
"description": "A simple Todo application API built with FastAPI",
"version": "1.0.0",
"documentation": "/docs",
"health_check": "/health"
}