Spaces:
Sleeping
Sleeping
| # status_check.py | |
| from typing import Optional, Tuple | |
| import os | |
| import requests | |
| def resolve_endpoint() -> Optional[str]: | |
| # however you get it today; env var is simplest | |
| return os.environ.get("HF_ENDPOINT_URI") | |
| def is_endpoint_healthy(uri: str, timeout: float = 5.0) -> Tuple[bool, str]: | |
| if not uri: | |
| return False, "No endpoint URI configured." | |
| try: | |
| r = requests.post(uri, json={"inputs": "ping"}, timeout=timeout) | |
| return (True, "OK") if r.ok else (False, f"HTTP {r.status_code}") | |
| except requests.exceptions.RequestException as e: | |
| return False, f"{type(e).__name__}" | |