Spaces:
Sleeping
Sleeping
Download api_client.py from Umer797/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 553 Bytes
-
https://huggingface.co/spaces/Umer797/Final_Assignment_Template/resolve/main/api_client.py
- Command line
-
hf download hf://spaces/Umer797/Final_Assignment_Template/api_client.py
-
curl -L -o api_client.py https://huggingface.co/spaces/Umer797/Final_Assignment_Template/resolve/main/api_client.py
553 Bytes
| import requests | |
| DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space" | |
| def fetch_questions(): | |
| response = requests.get(f"{DEFAULT_API_URL}/questions", timeout=15) | |
| response.raise_for_status() | |
| return response.json() | |
| def submit_answers(username, agent_code, answers): | |
| payload = { | |
| "username": username.strip(), | |
| "agent_code": agent_code, | |
| "answers": answers | |
| } | |
| response = requests.post(f"{DEFAULT_API_URL}/submit", json=payload, timeout=60) | |
| response.raise_for_status() | |
| return response.json() | |