from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware import uvicorn from api.routes import todos from db.database import Base, engine # Create tables Base.metadata.create_all(bind=engine) app = FastAPI( title="Todo API", description="A simple Todo API built with FastAPI and SQLite", version="1.0.0" ) # Configure CORS app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Include routers app.include_router(todos.router, prefix="/api") @app.get("/") def root(): return {"message": "Welcome to Todo API"} @app.get("/health") def health(): return {"status": "healthy"} if __name__ == "__main__": uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)