from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse from app.api.v1.api import api_router from app.core.config import settings app = FastAPI( title=settings.PROJECT_NAME, description=settings.PROJECT_DESCRIPTION, version=settings.VERSION, openapi_url=f"{settings.API_V1_STR}/openapi.json", docs_url="/docs", redoc_url="/redoc", ) # Configure CORS middleware app.add_middleware( CORSMiddleware, allow_origins=["*"], # Allow all domains allow_credentials=True, allow_methods=["*"], # Allow all methods allow_headers=["*"], # Allow all headers ) # Include API router app.include_router(api_router, prefix=settings.API_V1_STR) @app.get("/health", response_model=dict) async def health_check(): """Health check endpoint""" return {"status": "ok", "message": "Service is up and running"} @app.exception_handler(Exception) async def generic_exception_handler(request, exc): """Global exception handler""" return JSONResponse( status_code=500, content={"detail": str(exc), "success": False}, ) if __name__ == "__main__": import uvicorn uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)