from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware # Create basic app first app = FastAPI( title="School Portal API", version="1.0.0", description="School Portal API - A comprehensive school management system", openapi_url="/openapi.json", docs_url="/docs", redoc_url="/redoc" ) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Basic health check and root endpoints @app.get("/") async def root(): return { "title": "School Portal API", "version": "1.0.0", "description": "School Portal API - A comprehensive school management system", "documentation": "/docs", "health": "/health" } @app.get("/health") async def health_check(): return {"status": "healthy", "service": "School Portal API"} # Try to import API routes - if they fail, app still works try: from app.api.v1.api import api_router app.include_router(api_router, prefix="/api/v1") except Exception as e: # Add a fallback route to show the error @app.get("/api/v1/status") async def api_status(): return { "status": "API routes could not be loaded", "error": str(e), "message": "Basic health check is working" }