Automated Action a030964e07 Implement REST API with FastAPI and SQLite
- Set up project structure and dependencies
- Implement database models with SQLAlchemy
- Set up Alembic migrations
- Create FastAPI application with CORS support
- Implement API endpoints (CRUD operations)
- Add health check endpoint
- Update README with setup and usage instructions
2025-06-03 12:23:52 +00:00

30 lines
791 B
Python

from typing import Dict
from fastapi import APIRouter, Depends, status
from sqlalchemy.orm import Session
from sqlalchemy import text
from app.api.deps import get_db
from app.core.config import settings
router = APIRouter()
@router.get("/", status_code=status.HTTP_200_OK)
def health_check(db: Session = Depends(get_db)) -> Dict[str, str]:
"""
Check the health of the application.
Returns:
Dict with status and version information.
"""
# Check database connection
try:
db.execute(text("SELECT 1"))
db_status = "healthy"
except Exception:
db_status = "unhealthy"
return {
"status": "ok" if db_status == "healthy" else "error",
"version": settings.PROJECT_VERSION,
"database": db_status
}