File size: 565 Bytes
c4249e3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # 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 {}
|