eduardo-alvarez commited on
Commit
92d5c20
1 Parent(s): 38bbce8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -37,14 +37,19 @@ with demo:
37
  team for generously sharing their code and best
38
  practices, ensuring that AI Developers have a valuable and enjoyable tool at their disposal.""")
39
 
40
- client_ip = gr.Request.client.host
41
- local_ip = socket.gethostbyname(socket.gethostbyname(""))
42
- x_forwarded_for = gr.Request.headers.get('x-forwarded-for')
43
- headers = request.headers
44
- if x_forwarded_for:
45
- client_ip = x_forwarded_for
46
- gr.Markdown(f"client ip: {client_ip}")
47
- gr.Markdown(f"info: {x_forwarded_for}")
 
 
 
 
 
48
 
49
  with gr.Accordion("Chat with Top Models on the Leaderboard Here 💬", open=False):
50
  # import pdb
 
37
  team for generously sharing their code and best
38
  practices, ensuring that AI Developers have a valuable and enjoyable tool at their disposal.""")
39
 
40
+ def get_host_ip():
41
+ try:
42
+ # Create a socket connection to a public DNS server
43
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
44
+ s.connect(("8.8.8.8", 80)) # Google's public DNS server
45
+ IP = s.getsockname()[0]
46
+ s.close()
47
+ except Exception as e:
48
+ IP = "Unable to obtain IP: " + str(e)
49
+ return IP
50
+
51
+ server_ip = get_host_ip()
52
+ gr.Markdown(f"ip: {server_ip}")
53
 
54
  with gr.Accordion("Chat with Top Models on the Leaderboard Here 💬", open=False):
55
  # import pdb