Add application file3
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import time
|
3 |
+
import threading
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
def get_public_ip():
|
7 |
+
response = requests.get('https://api.ipify.org?format=json')
|
8 |
+
return response.json()["ip"]
|
9 |
+
|
10 |
+
def simulate_interaction():
|
11 |
+
# *** Placeholder for simulating activity within a real application ***
|
12 |
+
print("Simulating interaction...") # Example action
|
13 |
+
|
14 |
+
def background_interaction():
|
15 |
+
"""Performs simulated interaction in a background thread"""
|
16 |
+
while True:
|
17 |
+
simulate_interaction()
|
18 |
+
time.sleep(60 * 5) # Simulate interaction every 5 minutes
|
19 |
+
|
20 |
+
# Gradio interface with public IP display
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=get_public_ip,
|
23 |
+
outputs="text",
|
24 |
+
title="Public IP Retriever",
|
25 |
+
description="Displays the approximate public IP address."
|
26 |
+
)
|
27 |
+
|
28 |
+
# Start background interaction thread
|
29 |
+
interaction_thread = threading.Thread(target=background_interaction)
|
30 |
+
interaction_thread.start()
|
31 |
+
|
32 |
+
# Launch the Gradio interface
|
33 |
+
iface.launch()
|