Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,9 @@ def check_rate_limit(request: gr.Request):
|
|
44 |
# Check if rate limit exceeded
|
45 |
if len(request_times[ip]) >= MAX_REQUESTS:
|
46 |
time_remaining = int(TIME_WINDOW - (now - request_times[ip][0]))
|
47 |
-
|
|
|
|
|
48 |
|
49 |
# Add current request timestamp
|
50 |
request_times[ip].append(now)
|
|
|
44 |
# Check if rate limit exceeded
|
45 |
if len(request_times[ip]) >= MAX_REQUESTS:
|
46 |
time_remaining = int(TIME_WINDOW - (now - request_times[ip][0]))
|
47 |
+
time_remaining_minutes = time_remaining / 60
|
48 |
+
time_window_minutes = TIME_WINDOW / 60
|
49 |
+
return False, f"Rate limit exceeded. You can make {MAX_REQUESTS} requests per {time_window_minutes} minutes. Try again in {time_remaining_minutes} minutes."
|
50 |
|
51 |
# Add current request timestamp
|
52 |
request_times[ip].append(now)
|