Spaces:
Runtime error
Runtime error
Create x.py
Browse files
x.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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}")
|