Spaces:
Runtime error
Runtime error
next-social
commited on
Commit
·
1c5b4b7
1
Parent(s):
51507f3
add more
Browse files
app.py
CHANGED
@@ -73,6 +73,13 @@ count_client_map = ExpiringMap()
|
|
73 |
def infer(prompt: str, negative: str, width: int, height: int, sampler: str,
|
74 |
steps: int, seed: int, scale, request: gr.Request):
|
75 |
client_ip = request.client.host
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
if client_ip != '127.0.0.1' and client_ip != 'localhost' and client_ip != '0.0.0.0':
|
77 |
if time_client_map.get(client_ip):
|
78 |
return None, "Too many requests, please try again later."
|
|
|
73 |
def infer(prompt: str, negative: str, width: int, height: int, sampler: str,
|
74 |
steps: int, seed: int, scale, request: gr.Request):
|
75 |
client_ip = request.client.host
|
76 |
+
headers = request.kwargs['headers']
|
77 |
+
if headers and 'x-forwarded-for' in headers:
|
78 |
+
x_forwarded_for = headers['x-forwarded-for']
|
79 |
+
client_ip = x_forwarded_for.split(' ')[0] if x_forwarded_for else ""
|
80 |
+
|
81 |
+
print("client_ip", client_ip, text, "\n\n")
|
82 |
+
|
83 |
if client_ip != '127.0.0.1' and client_ip != 'localhost' and client_ip != '0.0.0.0':
|
84 |
if time_client_map.get(client_ip):
|
85 |
return None, "Too many requests, please try again later."
|