nadim71 commited on
Commit
17b928e
·
verified ·
1 Parent(s): 7bfe759

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -16
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
- response = requests.get(questions_url, timeout=15)
218
- response.raise_for_status()
219
- questions_data = response.json()
220
- if not questions_data:
221
- print("Fetched questions list is empty.")
 
222
  return "Fetched questions list is empty or invalid format.", None
223
- print(f"Fetched {len(questions_data)} questions.")
224
- except requests.exceptions.RequestException as e:
225
- print(f"Error fetching questions: {e}")
226
- return f"Error fetching questions: {e}", None
227
- except requests.exceptions.JSONDecodeError as e:
228
- print(f"Error decoding JSON response from questions endpoint: {e}")
229
- print(f"Response text: {response.text[:500]}")
230
- return f"Error decoding server response for questions: {e}", None
231
- except Exception as e:
232
- print(f"An unexpected error occurred fetching questions: {e}")
233
- return f"An unexpected error occurred fetching questions: {e}", None
 
 
 
 
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 = []