AC-Angelo93 commited on
Commit
d28006b
·
verified ·
1 Parent(s): bf69dcb

Create api_utils.py

Browse files
Files changed (1) hide show
  1. api_utils.py +12 -0
api_utils.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ def fetch_questions(api_url: str) -> list:
4
+ response = requests.get(api_url)
5
+ response.raise_for_status()
6
+ return response.json()
7
+
8
+ def submit_answers(api_url: str, username: str, answers: list) -> dict:
9
+ payload = {"username": username, "submission": answers}
10
+ response = requests.post(api_url, json=payload)
11
+ response.raise_for_status()
12
+ return response.json()