from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from app.db.session import get_db router = APIRouter() @router.get("/health", tags=["Health"]) async def health_check(db: Session = Depends(get_db)): """ Health check endpoint that reports on the application's health. Returns OK if the application is running and can connect to the database. """ try: # Try to execute a simple query to check database connectivity db.execute("SELECT 1") db_status = "OK" except Exception as e: db_status = f"Error: {str(e)}" return { "status": "OK", "database": db_status, }