feat: endpoint /health avec tests (8 tests)
Ajoute GET /health retournant un JSON avec : - status: "ok" - version: "2.1.0" - ollama: true/false (connectivité testée avec timeout 2s) - timestamp: ISO 8601 UTC Tests couvrent : format JSON, champs requis, Ollama joignable/injoignable, format timestamp ISO, type booléen du champ ollama. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -616,4 +616,21 @@ def create_app() -> Flask:
|
||||
metrics=metrics, total_selection=len(selection),
|
||||
groups=groups)
|
||||
|
||||
# --- Health check endpoint ---
|
||||
@app.route("/health")
|
||||
def health():
|
||||
from datetime import datetime, timezone
|
||||
ollama_ok = False
|
||||
try:
|
||||
r = requests.get(f"{OLLAMA_URL}/api/tags", timeout=2)
|
||||
ollama_ok = r.status_code == 200
|
||||
except Exception:
|
||||
pass
|
||||
return jsonify({
|
||||
"status": "ok",
|
||||
"version": "2.1.0",
|
||||
"ollama": ollama_ok,
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
})
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user