Spaces:
Runtime error
Runtime error
Srinivasulu kethanaboina commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,16 +3,18 @@ import requests
|
|
| 3 |
|
| 4 |
def get_public_ip_address():
|
| 5 |
try:
|
| 6 |
-
response = requests.get('
|
|
|
|
| 7 |
ip_address = response.json().get('ip', 'Unknown IP Address')
|
| 8 |
-
except requests.RequestException:
|
| 9 |
-
ip_address = 'Unable to retrieve IP address'
|
| 10 |
return f"Your Public IP Address is: {ip_address}"
|
| 11 |
|
| 12 |
-
iface = gr.Interface(
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
| 3 |
|
| 4 |
def get_public_ip_address():
|
| 5 |
try:
|
| 6 |
+
response = requests.get('(link unavailable)')
|
| 7 |
+
response.raise_for_status() # Raise an exception for bad status codes
|
| 8 |
ip_address = response.json().get('ip', 'Unknown IP Address')
|
| 9 |
+
except requests.RequestException as e:
|
| 10 |
+
ip_address = f'Unable to retrieve IP address: {e}'
|
| 11 |
return f"Your Public IP Address is: {ip_address}"
|
| 12 |
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=get_public_ip_address,
|
| 15 |
+
inputs=[],
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Public IP Address Display",
|
| 18 |
+
description="This app shows your public IP address."
|
| 19 |
+
)
|
| 20 |
+
iface.launch()
|