Automated Action f55cad6274 Create Todo application with FastAPI
- Set up project structure with FastAPI
- Implement Todo model and database connection
- Set up Alembic for database migrations
- Create CRUD API endpoints for Todo management
- Add health endpoint for application monitoring
- Update README with project documentation

generated with BackendIM... (backend.im)
2025-05-14 01:20:30 +00:00

23 lines
492 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter(
prefix="/health",
tags=["health"],
)
@router.get("/")
def health_check(db: Session = Depends(get_db)):
try:
# Check if database is accessible
db.execute("SELECT 1")
db_status = "ok"
except Exception as e:
db_status = f"error: {str(e)}"
return {
"status": "ok",
"database": db_status
}