Automated Action 9505ec13a1 Implement simple todo application with FastAPI and SQLite
- Set up project structure and FastAPI app
- Create database models and SQLAlchemy connection
- Implement Alembic migration scripts
- Add CRUD API endpoints for Todo items
- Add health check endpoint
- Set up validation, error handling, and middleware
- Add comprehensive documentation in README.md
2025-05-18 12:42:38 +00:00

38 lines
1004 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routes import router as api_router
from app.core.config import settings
from app.core.error_handlers import add_error_handlers
from app.middleware.logging import add_logging_middleware
app = FastAPI(
title=settings.PROJECT_NAME,
description="Simple Todo Application API",
version="0.1.0",
docs_url="/docs",
redoc_url="/redoc",
)
# Set up CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ORIGINS,
allow_credentials=settings.CORS_ALLOW_CREDENTIALS,
allow_methods=settings.CORS_ALLOW_METHODS,
allow_headers=settings.CORS_ALLOW_HEADERS,
)
# Add logging middleware
add_logging_middleware(app)
# Add global error handlers
add_error_handlers(app)
# Include API router
app.include_router(api_router, prefix=settings.API_V1_STR)
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)