
- Set up project structure with FastAPI and dependency files - Configure SQLAlchemy with SQLite database - Implement user authentication using JWT tokens - Create comprehensive API routes for user management - Add health check endpoint for application monitoring - Set up Alembic for database migrations - Add detailed documentation in README.md
26 lines
667 B
Python
26 lines
667 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health", tags=["Health"])
|
|
async def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint that reports on the application's health.
|
|
Returns OK if the application is running and can connect to the database.
|
|
"""
|
|
try:
|
|
# Try to execute a simple query to check database connectivity
|
|
db.execute("SELECT 1")
|
|
db_status = "OK"
|
|
except Exception as e:
|
|
db_status = f"Error: {str(e)}"
|
|
|
|
return {
|
|
"status": "OK",
|
|
"database": db_status,
|
|
}
|