2025-06-01 10:05:16 +00:00

38 lines
975 B
Python

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
# Create FastAPI app
app = FastAPI(
title=settings.PROJECT_NAME,
openapi_url="/openapi.json",
)
# Configure CORS
if settings.BACKEND_CORS_ORIGINS:
app.add_middleware(
CORSMiddleware,
allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include API router
app.include_router(api_router, prefix=settings.API_V1_STR)
# Health check endpoint
@app.get("/health", response_model=None)
async def health_check():
"""
Health check endpoint to verify the API is running.
"""
return JSONResponse(content={"status": "healthy"})
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)