feat: добавить API, compose, nginx и отчёт для лабораторной 3
Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..db import get_db if False else None # placeholder to avoid circular import
|
||||
from ..deps import get_db
|
||||
from ..errors import ApiError
|
||||
from ..schemas import Health
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/health/live", response_model=Health)
|
||||
def live():
|
||||
return Health()
|
||||
|
||||
|
||||
@router.get("/health/ready", response_model=Health)
|
||||
def ready(db: Session = Depends(get_db)):
|
||||
try:
|
||||
db.execute(text("SELECT 1"))
|
||||
except Exception:
|
||||
raise ApiError(503, "unavailable", "База данных недоступна")
|
||||
return Health()
|
||||
Reference in New Issue
Block a user