39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from fastapi import FastAPI, status
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.base import api_router
|
|
from app.core.config import settings
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
|
)
|
|
|
|
# Set all CORS enabled origins
|
|
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=["*"],
|
|
)
|
|
|
|
|
|
# Add root health check endpoint
|
|
@app.get("/health", tags=["health"], status_code=status.HTTP_200_OK)
|
|
async def health_check():
|
|
"""
|
|
Root health check endpoint.
|
|
This endpoint is used for server health monitoring.
|
|
"""
|
|
return {"status": "ok"}
|
|
|
|
|
|
# Include API routes
|
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run("main:app", host=settings.HOST, port=settings.PORT, reload=True)
|