Spaces:
Sleeping
Sleeping
| """FastAPI application factory for the backend.""" | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from backend.api.routes import router as api_router | |
| def create_app() -> FastAPI: | |
| """ | |
| Create and configure the FastAPI application. | |
| Returns: | |
| Configured FastAPI instance with routes and middleware. | |
| """ | |
| app = FastAPI( | |
| title="Rubric AI API", | |
| description="Backend API for Rubric AI educational assessment tool", | |
| version="1.0.0", | |
| ) | |
| # Add CORS middleware for development | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Include API routes with /api prefix to avoid NiceGUI mount conflicts | |
| app.include_router(api_router, prefix="/api") | |
| # Health check endpoint | |
| async def health_check(): | |
| return {"status": "healthy"} | |
| return app | |