radames commited on
Commit
13e8f5d
·
1 Parent(s): 6ac145e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -5,9 +5,8 @@ def predict(text, request: gr.Request):
5
  client_ip = request.client.host
6
  local_ip = socket.gethostbyname(socket.gethostbyname(""))
7
  print(request)
8
- headers = request.headers
9
- if headers and 'x-forwarded-for' in headers:
10
- x_forwarded_for = headers['x-forwarded-for']
11
  client_ip = x_forwarded_for.split(' ')[0] if x_forwarded_for else ""
12
 
13
  print("client_ip", client_ip, text, "\n\n")
 
5
  client_ip = request.client.host
6
  local_ip = socket.gethostbyname(socket.gethostbyname(""))
7
  print(request)
8
+ x_forwarded_for = request.headers.get('x-forwarded-for')
9
+ if x_forwarded_for:
 
10
  client_ip = x_forwarded_for.split(' ')[0] if x_forwarded_for else ""
11
 
12
  print("client_ip", client_ip, text, "\n\n")