Automated Action 43ed4aaa3f Create simple todo application with FastAPI and SQLite
- Set up project structure with FastAPI and SQLite
- Created Todo model with SQLAlchemy ORM
- Added CRUD operations for todos
- Implemented API endpoints for Todo operations
- Added health check endpoint
- Added Alembic for database migrations
- Updated README with documentation

generated with BackendIM... (backend.im)
2025-05-13 12:04:52 +00:00

25 lines
653 B
Python

from fastapi import APIRouter, Depends, status
from sqlalchemy.orm import Session
from sqlalchemy import text
from app.database.base import get_db
router = APIRouter()
@router.get("/health", status_code=status.HTTP_200_OK)
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint to verify the API and database are operational.
"""
# Check database connection
try:
db.execute(text("SELECT 1"))
db_status = "healthy"
except Exception as e:
db_status = f"unhealthy: {str(e)}"
return {
"status": "healthy",
"database": db_status,
"version": "0.1.0"
}