Update app.py
Browse files
app.py
CHANGED
@@ -8,10 +8,10 @@ def predict(text, request: gr.Request):
|
|
8 |
headers = request.headers
|
9 |
real_client_ip = ""
|
10 |
print(headers)
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
return text, {"real_client_ip": real_client_ip,
|
17 |
"client_ip": client_ip,
|
|
|
8 |
headers = request.headers
|
9 |
real_client_ip = ""
|
10 |
print(headers)
|
11 |
+
if headers['x-forwarded-for']:
|
12 |
+
x_forwarded_for = headers['x-forwarded-for']
|
13 |
+
real_client_ip = x_forwarded_for.split(
|
14 |
+
' ')[0] if x_forwarded_for else ""
|
15 |
|
16 |
return text, {"real_client_ip": real_client_ip,
|
17 |
"client_ip": client_ip,
|