Automated Action 16cfcd783e Build Chat Application Backend with FastAPI and SQLite
- Set up project structure with FastAPI and SQLite
- Implement user authentication using JWT
- Create database models for users, conversations, and messages
- Implement API endpoints for user management and chat functionality
- Set up WebSocket for real-time messaging
- Add database migrations with Alembic
- Create health check endpoint
- Update README with comprehensive documentation

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

23 lines
557 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter(tags=["health"])
@router.get("/health")
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint to verify API is up and running and can connect to the database
"""
try:
# Try to connect to the database
db.execute("SELECT 1")
db_status = "up"
except Exception:
db_status = "down"
return {
"status": "ok",
"database": db_status
}