Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| # Create FastAPI app instance | |
| app = FastAPI( | |
| title="Todo API", | |
| description="A secure, multi-user todo management API with JWT authentication", | |
| version="1.0.0", | |
| openapi_url="/api/openapi.json", | |
| docs_url="/api/docs", | |
| redoc_url="/api/redoc" | |
| ) | |
| # Add CORS middleware with basic configuration to avoid importing settings | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # Allow all origins for testing | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| # Expose authorization header to allow frontend to access JWT tokens | |
| expose_headers=["Authorization"] | |
| ) | |
| def read_root(): | |
| return {"message": "Welcome to the Todo API"} | |
| def health_check(): | |
| return {"status": "healthy", "service": "todo-backend"} | |
| # Basic task endpoints without complex models | |
| def get_tasks(): | |
| return {"tasks": []} | |
| def create_task(): | |
| return {"message": "Task created successfully"} |