35 lines
814 B
Python
35 lines
814 B
Python
from settings import app
|
|
from sqlalchemy import text
|
|
from sqlalchemy.exc import SQLAlchemyError
|
|
from settings import db
|
|
from .token_routes import * # noqa: F401 F403
|
|
from .user_routes import * # noqa: F401 F403
|
|
from .contact_routes import * # noqa: F401 F403
|
|
|
|
|
|
@app.route("/api/test")
|
|
def test_route():
|
|
"""Test."""
|
|
return {"success": True}
|
|
|
|
|
|
@app.get("/api/health")
|
|
def health():
|
|
"""Backward-compatible liveness probe."""
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/api/health/live")
|
|
def health_live():
|
|
return {"status": "ok"}
|
|
|
|
|
|
@app.get("/api/health/ready")
|
|
def health_ready():
|
|
try:
|
|
db.session.execute(text("SELECT 1"))
|
|
except SQLAlchemyError:
|
|
app.logger.error("Database readiness check failed")
|
|
return {"status": "unavailable"}, 503
|
|
return {"status": "ready"}
|