Automated Action 512d53de73 Create simple Todo application with FastAPI and SQLite
- Created CRUD operations for todos
- Added database models and SQLAlchemy integration
- Set up Alembic for database migrations
- Added health endpoint
- Updated README with installation and usage instructions

generated with BackendIM... (backend.im)
2025-05-12 10:34:56 +00:00

22 lines
530 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)):
"""
Health check endpoint to verify API and database status
"""
try:
# Check database connection
db.execute("SELECT 1")
db_status = "healthy"
except Exception as e:
db_status = f"unhealthy: {str(e)}"
return {
"status": "up",
"database": db_status
}