22 lines
547 B
Python
22 lines
547 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.db.deps import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint to verify API is working and database is connected.
|
|
"""
|
|
try:
|
|
# Try to execute a simple query to verify database connection
|
|
db.execute("SELECT 1")
|
|
db_status = "connected"
|
|
except Exception:
|
|
db_status = "disconnected"
|
|
|
|
return {"status": "ok", "database": db_status}
|