Automated Action 6341d8f5a0 Create Todo application with FastAPI and SQLite
- Set up project structure and requirements
- Create database models and connection setup using SQLAlchemy
- Set up Alembic migrations
- Create API endpoints for Todo CRUD operations
- Add health endpoint
- Update README with project information

generated with BackendIM... (backend.im)
2025-05-13 11:29:47 +00:00

22 lines
577 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from sqlalchemy import text
from app.database.database import get_db
router = APIRouter(tags=["health"])
@router.get("/health")
def health_check(db: Session = Depends(get_db)):
# Try to execute a simple query to check database connection
try:
db.execute(text("SELECT 1"))
db_status = "healthy"
except Exception as e:
db_status = f"unhealthy: {str(e)}"
return {
"status": "ok",
"database_status": db_status,
"version": "1.0.0"
}