Automated Action db9aa8e5e2 Create FastAPI Todo API with SQLite
Generated with BackendIM... (backend.im)
2025-05-13 10:29:43 +00:00

29 lines
642 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from sqlalchemy import text
from app.db.session import get_db
router = APIRouter()
@router.get("/health")
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint.
Returns:
dict: Status of the service and its dependencies.
"""
# Check database connectivity
try:
db.execute(text("SELECT 1"))
db_status = "healthy"
except Exception as e:
db_status = f"unhealthy: {str(e)}"
return {
"status": "healthy",
"database": db_status,
"version": "0.1.0"
}