Ubik80 commited on
Commit
d1c8ce2
·
verified ·
1 Parent(s): 9307ac3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -32,12 +32,21 @@ def run_and_submit_all(username):
32
  if not username:
33
  return "Please enter your Hugging Face username.", None
34
 
35
- # Fetch questions
36
  try:
37
  resp = requests.get(f"{DEFAULT_API_URL}/questions", timeout=15)
 
 
 
38
  resp.raise_for_status()
39
  questions = resp.json()
40
- except Exception as e:
 
 
 
 
 
 
41
  return f"Error fetching questions: {e}", None
42
 
43
  # Run agent on all questions
 
32
  if not username:
33
  return "Please enter your Hugging Face username.", None
34
 
35
+ # Fetch questions
36
  try:
37
  resp = requests.get(f"{DEFAULT_API_URL}/questions", timeout=15)
38
+ # Handle rate limiting specifically
39
+ if resp.status_code == 429:
40
+ return "Server rate limited the requests. Please wait a moment and try again.", None
41
  resp.raise_for_status()
42
  questions = resp.json()
43
+ except requests.exceptions.HTTPError as e:
44
+ # Specific HTTP errors not caught above
45
+ status_code = getattr(e.response, 'status_code', None)
46
+ if status_code == 429:
47
+ return "Server rate limited the requests. Please wait a moment and try again.", None
48
+ return f"Error fetching questions: {e}", None
49
+ except requests.exceptions.RequestException as e:
50
  return f"Error fetching questions: {e}", None
51
 
52
  # Run agent on all questions