Download utils/api_client.py from Sujith2121/drowsiness_detection_frontend: direct link, hf CLI and curl.
- Browser
- Download file 565 Bytes
-
https://huggingface.co/spaces/Sujith2121/drowsiness_detection_frontend/resolve/main/utils/api_client.py
- Command line
-
hf download hf://spaces/Sujith2121/drowsiness_detection_frontend/utils/api_client.py
-
curl -L -o api_client.py https://huggingface.co/spaces/Sujith2121/drowsiness_detection_frontend/resolve/main/utils/api_client.py
565 Bytes
| # utils/api_client.py | |
| import requests | |
| BASE_URL = "https://sujith2121-drowsiness-detection-backend.hf.space" | |
| def post_event(source: str): | |
| try: | |
| payload = {"source": source} | |
| requests.post(f"{BASE_URL}/detect", json=payload) | |
| except Exception as e: | |
| print("API error:", e) | |
| def get_events(): | |
| try: | |
| res = requests.get(f"{BASE_URL}/events") | |
| return res.json() | |
| except: | |
| return [] | |
| def get_stats(): | |
| try: | |
| res = requests.get(f"{BASE_URL}/stats") | |
| return res.json() | |
| except: | |
| return {} | |