Automated Action ba478ce2d3 Implement Task Manager API with FastAPI and SQLite
Create a full-featured task management API with the following components:
- RESTful CRUD operations for tasks
- Task status and priority management
- SQLite database with SQLAlchemy ORM
- Alembic migrations
- Health check endpoint
- Comprehensive API documentation
2025-05-30 22:50:55 +00:00

39 lines
759 B
Python

"""
Health check endpoint.
"""
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter()
class HealthCheck(BaseModel):
"""
Health check response schema.
"""
status: str
database: bool
@router.get("", response_model=HealthCheck)
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint.
Returns:
HealthCheck: Health status including database connectivity.
"""
# Check if database is accessible
try:
db.execute("SELECT 1")
db_status = True
except Exception:
db_status = False
return {
"status": "healthy",
"database": db_status
}