File size: 947 Bytes
49cb8ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import requests
import time
import threading
import gradio as gr

def get_public_ip():
    response = requests.get('https://api.ipify.org?format=json')
    return response.json()["ip"]

def simulate_interaction():
    # *** Placeholder for simulating activity within a real application ***   
    print("Simulating interaction...")  # Example action

def background_interaction():
    """Performs simulated interaction in a background thread"""
    while True:
        simulate_interaction()
        time.sleep(60 * 5)  # Simulate interaction every 5 minutes

# Gradio interface with public IP display
iface = gr.Interface(
    fn=get_public_ip, 
    outputs="text", 
    title="Public IP Retriever",
    description="Displays the approximate public IP address."
)

# Start background interaction thread
interaction_thread = threading.Thread(target=background_interaction)
interaction_thread.start()

# Launch the Gradio interface
iface.launch()