Spaces:
Runtime error
Runtime error
Update x.py
Browse files
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 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
except Exception as e:
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|