Sujith2121's picture
Create utils/api_client.py
c4249e3 verified
raw
history blame contribute delete
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 {}