from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.api import health, todos app = FastAPI( title="Simple Todo App", description="A simple todo application API", version="0.1.0", ) # Add CORS middleware app.add_middleware( CORSMiddleware, allow_origins=["*"], # Allow all origins allow_credentials=True, allow_methods=["*"], # Allow all methods allow_headers=["*"], # Allow all headers ) # Include routers app.include_router(todos.router, prefix="/api/v1", tags=["todos"]) app.include_router(health.router, tags=["health"]) # Expose OpenAPI at root @app.get("/openapi.json", include_in_schema=False) async def get_open_api_endpoint(): return app.openapi() if __name__ == "__main__": import uvicorn uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)