Automated Action 4d6c2e1778 Implement Anime Information API with FastAPI and SQLite
- Create project structure and dependencies
- Set up SQLAlchemy models for anime, genres, and their relationships
- Implement CRUD operations for all models
- Set up FastAPI endpoints for managing anime and genres
- Add health check endpoint
- Configure Alembic for database migrations
- Add data seeding capability
- Update README with project information
2025-05-17 21:37:16 +00:00

30 lines
707 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from pydantic import BaseModel
from app.api import deps
router = APIRouter()
class HealthCheck(BaseModel):
status: str
db_connection: bool
@router.get("", response_model=HealthCheck)
def health_check(db: Session = Depends(deps.get_db)):
"""
Check the health of the application.
"""
# Check database connection
try:
# Try to execute a simple query to verify connection
db.execute("SELECT 1")
db_connection = True
except Exception:
db_connection = False
return {
"status": "ok" if db_connection else "error",
"db_connection": db_connection
}