eduardo-alvarez commited on
Commit
9773d33
1 Parent(s): 92d5c20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -37,19 +37,18 @@ 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
- 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
 
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
+
41
+ def get_public_ip():
42
  try:
43
+ response = requests.get('https://api.ipify.org')
44
+ public_ip = response.text
45
+ return public_ip
 
 
46
  except Exception as e:
47
+ return f"Error: {str(e)}"
48
+
49
+ public_ip = get_public_ip()
50
 
51
+ gr.Markdown(f"ip: {public_ip}")
 
52
 
53
  with gr.Accordion("Chat with Top Models on the Leaderboard Here 💬", open=False):
54
  # import pdb