Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -214,23 +214,28 @@ if __name__ == "__main__":
|
|
| 214 |
# 2. Fetch Questions
|
| 215 |
print(f"Fetching questions from: {questions_url}")
|
| 216 |
try:
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
| 222 |
return "Fetched questions list is empty or invalid format.", None
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
# 3. Run your Agent
|
| 236 |
results_log = []
|
|
|
|
| 214 |
# 2. Fetch Questions
|
| 215 |
print(f"Fetching questions from: {questions_url}")
|
| 216 |
try:
|
| 217 |
+
response = requests.get(questions_url, timeout=15)
|
| 218 |
+
response.raise_for_status()
|
| 219 |
+
questions_data = response.json()
|
| 220 |
+
|
| 221 |
+
if not questions_data:
|
| 222 |
+
print("Fetched questions list is empty.")
|
| 223 |
return "Fetched questions list is empty or invalid format.", None
|
| 224 |
+
|
| 225 |
+
print(f"Fetched {len(questions_data)} questions.")
|
| 226 |
+
|
| 227 |
+
except requests.exceptions.RequestException as e:
|
| 228 |
+
print(f"Error fetching questions: {e}")
|
| 229 |
+
return f"Error fetching questions: {e}", None
|
| 230 |
+
|
| 231 |
+
except requests.exceptions.JSONDecodeError as e:
|
| 232 |
+
print(f"Error decoding JSON response: {e}")
|
| 233 |
+
print(f"Response text: {response.text[:500]}")
|
| 234 |
+
return f"Error decoding server response: {e}", None
|
| 235 |
+
|
| 236 |
+
except Exception as e:
|
| 237 |
+
print(f"Unexpected error: {e}")
|
| 238 |
+
return f"Unexpected error: {e}", None
|
| 239 |
|
| 240 |
# 3. Run your Agent
|
| 241 |
results_log = []
|