
- Set up project structure and FastAPI application - Create Todo database model with SQLAlchemy - Configure Alembic for database migrations - Implement CRUD endpoints for managing Todo items - Add health check endpoint - Include comprehensive documentation in README.md - Configure and apply Ruff linting
20 lines
553 B
Python
20 lines
553 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health", tags=["health"])
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint that verifies database connection
|
|
"""
|
|
try:
|
|
# Execute a simple query to verify the database is working
|
|
db.execute("SELECT 1")
|
|
return {"status": "healthy", "database": "connected"}
|
|
except Exception as e:
|
|
return {"status": "unhealthy", "database": str(e)}
|