from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware app = FastAPI( title="Todo App API", description="A simple Todo application API built with FastAPI", version="1.0.0", openapi_url="/openapi.json", docs_url="/docs", redoc_url="/redoc" ) # Configure CORS app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) @app.get("/") async def root(): """Base endpoint that returns app information""" return { "title": "Todo App API", "description": "A simple Todo application API built with FastAPI", "version": "1.0.0", "documentation": "/docs", "health_check": "/health" } @app.get("/health") async def health_check(): """Health check endpoint""" return {"status": "healthy", "message": "Todo App API is running"} if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000)