|
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(): |
|
|
|
print("Simulating interaction...") |
|
|
|
def background_interaction(): |
|
"""Performs simulated interaction in a background thread""" |
|
while True: |
|
simulate_interaction() |
|
time.sleep(60 * 5) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=get_public_ip, |
|
outputs="text", |
|
title="Public IP Retriever", |
|
description="Displays the approximate public IP address." |
|
) |
|
|
|
|
|
interaction_thread = threading.Thread(target=background_interaction) |
|
interaction_thread.start() |
|
|
|
|
|
iface.launch() |
|
|