TensorGuy01 commited on
Commit
285cf49
·
verified ·
1 Parent(s): 5790cdd

Update x.py

Browse files
Files changed (1) hide show
  1. x.py +12 -5
x.py CHANGED
@@ -1,11 +1,18 @@
1
  import requests
 
2
 
3
  def check_ip_region():
4
  try:
5
  ip_info = requests.get("https://ipinfo.io/json", timeout=5).json()
6
- print(f"Public IP: {ip_info.get('ip')}")
7
- print(f"Region: {ip_info.get('region')}")
8
- print(f"Country: {ip_info.get('country')}")
9
- print(f"City: {ip_info.get('city')}")
 
 
10
  except Exception as e:
11
- print(f"Failed to get IP info: {e}")
 
 
 
 
 
1
  import requests
2
+ import gradio as gr
3
 
4
  def check_ip_region():
5
  try:
6
  ip_info = requests.get("https://ipinfo.io/json", timeout=5).json()
7
+ result = (
8
+ f"Public IP: {ip_info.get('ip')}\n"
9
+ f"Region: {ip_info.get('region')}\n"
10
+ f"Country: {ip_info.get('country')}\n"
11
+ f"City: {ip_info.get('city')}"
12
+ )
13
  except Exception as e:
14
+ result = f"Failed to get IP info: {e}"
15
+ return result
16
+
17
+ iface = gr.Interface(fn=check_ip_region, inputs=[], outputs="text")
18
+ iface.launch()