chatbot / healthcheck.py
SuhasGholkar's picture
Create healthcheck.py
d119a29 verified
raw
history blame contribute delete
315 Bytes
import os, sys, urllib.request
port = int(os.environ.get("PORT", "7860"))
url = f"http://127.0.0.1:{port}/_stcore/health"
try:
with urllib.request.urlopen(url, timeout=3) as resp:
ok = resp.status == 200 and b"ok" in resp.read().lower()
sys.exit(0 if ok else 1)
except Exception:
sys.exit(1)