Spaces:
Sleeping
Sleeping
Srinivasulu kethanaboina
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,66 +1,11 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def get_ip_html():
|
4 |
-
html_code = """
|
5 |
-
<!DOCTYPE html>
|
6 |
-
<html lang="en">
|
7 |
-
<head>
|
8 |
-
<meta charset="UTF-8">
|
9 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
10 |
-
<title>Public IP Address</title>
|
11 |
-
</head>
|
12 |
-
<body>
|
13 |
-
<h1 id="welcome-message">Welcome to Gradio!</h1>
|
14 |
-
<p id="ip-address">Loading your public IP address...</p>
|
15 |
-
|
16 |
-
<script>
|
17 |
-
async function fetchPublicIP() {
|
18 |
-
try {
|
19 |
-
const response = await fetch('https://api.ipify.org?format=json');
|
20 |
-
const data = await response.json();
|
21 |
-
document.getElementById('ip-address').textContent = 'Your Public IP Address is: ' + data.ip;
|
22 |
-
} catch (error) {
|
23 |
-
document.getElementById('ip-address').textContent = 'Unable to retrieve IP address';
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
27 |
-
function createGradioAnimation() {
|
28 |
-
var container = document.createElement('div');
|
29 |
-
container.id = 'gradio-animation';
|
30 |
-
container.style.fontSize = '2em';
|
31 |
-
container.style.fontWeight = 'bold';
|
32 |
-
container.style.textAlign = 'center';
|
33 |
-
container.style.marginBottom = '20px';
|
34 |
-
|
35 |
-
var text = 'Welcome to Gradio!';
|
36 |
-
for (var i = 0; i < text.length; i++) {
|
37 |
-
(function(i){
|
38 |
-
setTimeout(function(){
|
39 |
-
var letter = document.createElement('span');
|
40 |
-
letter.style.opacity = '0';
|
41 |
-
letter.style.transition = 'opacity 0.5s';
|
42 |
-
letter.innerText = text[i];
|
43 |
|
44 |
-
container.appendChild(letter);
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
}, i * 250);
|
50 |
-
})(i);
|
51 |
-
}
|
52 |
-
|
53 |
-
var gradioContainer = document.querySelector('.gradio-container');
|
54 |
-
gradioContainer.insertBefore(container, gradioContainer.firstChild);
|
55 |
-
}
|
56 |
-
|
57 |
-
fetchPublicIP();
|
58 |
-
createGradioAnimation();
|
59 |
-
</script>
|
60 |
-
</body>
|
61 |
-
</html>
|
62 |
-
"""
|
63 |
-
return html_code
|
64 |
|
65 |
with gr.Blocks() as demo:
|
66 |
gr.HTML(get_ip_html)
|
|
|
1 |
import gradio as gr
|
2 |
+
import ip_address as ip
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
|
|
5 |
|
6 |
+
def get_ip_html():
|
7 |
+
address = ip.get()
|
8 |
+
return address
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
with gr.Blocks() as demo:
|
11 |
gr.HTML(get_ip_html)
|