Automated Action c139318961 Implement simple Todo application with FastAPI and SQLite
- Set up project structure with FastAPI application
- Create Todo model and related Pydantic schemas
- Implement CRUD operations for Todo items
- Add health endpoint for application monitoring
- Configure database connection with SQLite
- Create database migrations with Alembic
- Update documentation with setup and usage instructions

generated with BackendIM... (backend.im)
2025-05-12 16:30:31 +00:00

24 lines
731 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db.database import get_db
router = APIRouter()
@router.get("/health", summary="Check the health of the application")
def health_check(db: Session = Depends(get_db)):
"""
Check that the application is running and the database is accessible.
"""
try:
# Check if we can access the database
db.execute("SELECT 1")
return {
"status": "ok",
"message": "Application is running and database is connected"
}
except Exception as e:
return {
"status": "error",
"message": f"Application is running but database connection failed: {str(e)}"
}