Automated Action 8e26cae20e Initial Todo app backend implementation with FastAPI and SQLite
- Created FastAPI application structure
- Added Todo model and CRUD operations
- Added database integration with SQLAlchemy
- Added migrations with Alembic
- Added health endpoint
- Added API documentation with Swagger UI and ReDoc
2025-05-16 00:35:49 +00:00

32 lines
882 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from api.routers import todo_router, health_router
from db.database import create_tables
app = FastAPI(
title="SimpleTodoApp API",
description="API for a simple todo application",
version="0.1.0",
)
# CORS settings
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # For development, in production specify your frontend domain
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(todo_router.router, prefix="/api/todos", tags=["todos"])
app.include_router(health_router.router, tags=["health"])
# Create database tables on startup
@app.on_event("startup")
async def startup():
create_tables()
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)