
- Set up project structure with FastAPI and SQLite - Implement Todo model and CRUD operations - Add health endpoint for application monitoring - Configure Alembic for database migrations - Add comprehensive documentation generated with BackendIM... (backend.im)
19 lines
479 B
Python
19 lines
479 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from app.database import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/health")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
try:
|
|
# Make a simple query to check database connectivity
|
|
db.execute("SELECT 1")
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "ok",
|
|
"database": db_status
|
|
} |