Spaces:
Runtime error
Runtime error
Srinivasulu kethanaboina commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import requests
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
iface = gr.Interface(
|
| 14 |
-
fn=
|
| 15 |
-
inputs=[],
|
| 16 |
-
outputs=
|
| 17 |
-
title="Public IP Address Display",
|
| 18 |
description="This app shows your public IP address."
|
| 19 |
)
|
| 20 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
|
| 4 |
import gradio as gr
|
|
|
|
| 5 |
|
| 6 |
+
def get_html_with_ip():
|
| 7 |
+
html_code = """
|
| 8 |
+
<!DOCTYPE html>
|
| 9 |
+
<html lang="en">
|
| 10 |
+
<head>
|
| 11 |
+
<meta charset="UTF-8">
|
| 12 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 13 |
+
<title>Public IP Address</title>
|
| 14 |
+
<style>
|
| 15 |
+
body {
|
| 16 |
+
font-family: Arial, sans-serif;
|
| 17 |
+
text-align: center;
|
| 18 |
+
}
|
| 19 |
+
</style>
|
| 20 |
+
</head>
|
| 21 |
+
<body>
|
| 22 |
+
<h1>Your Public IP Address</h1>
|
| 23 |
+
<p id="ip-address">Loading...</p>
|
| 24 |
+
<script>
|
| 25 |
+
async function fetchPublicIP() {
|
| 26 |
+
try {
|
| 27 |
+
const response = await fetch('(link unavailable)');
|
| 28 |
+
const data = await response.json();
|
| 29 |
+
document.getElementById('ip-address').textContent = data.ip;
|
| 30 |
+
} catch (error) {
|
| 31 |
+
document.getElementById('ip-address').textContent = 'Unable to retrieve IP address';
|
| 32 |
+
console.error(error);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
fetchPublicIP();
|
| 36 |
+
</script>
|
| 37 |
+
</body>
|
| 38 |
+
</html>
|
| 39 |
+
"""
|
| 40 |
+
return html_code
|
| 41 |
+
|
| 42 |
|
| 43 |
iface = gr.Interface(
|
| 44 |
+
fn=get_html_with_ip,
|
| 45 |
+
inputs=[],
|
| 46 |
+
outputs=gr.outputs.HTML(),
|
| 47 |
+
title="Public IP Address Display",
|
| 48 |
description="This app shows your public IP address."
|
| 49 |
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
iface.launch()
|