|
import gradio as gr |
|
import threading |
|
import requests |
|
import time |
|
|
|
def send_dummy_request(space_url): |
|
try: |
|
response = requests.get(space_url) |
|
|
|
print(f"Response Status Code Of Wait: {response.status_code}") |
|
except Exception as e: |
|
print(f"Error: {e}") |
|
|
|
def send_dummy_request_self(space_url_self): |
|
try: |
|
response = requests.get(space_url_self) |
|
|
|
print(f"Response Status Code Of Self: {response.status_code}") |
|
except Exception as e: |
|
print(f"Error: {e}") |
|
|
|
def background_request(space_url,space_url_self, interval_seconds): |
|
try: |
|
while True: |
|
send_dummy_request(space_url) |
|
send_dummy_request_self(space_url_self) |
|
time.sleep(interval_seconds) |
|
except KeyboardInterrupt: |
|
print("Background script terminated by user.") |
|
|
|
|
|
space_url = 'https://huggingface.co/spaces/clone3/Wait' |
|
space_url_self = 'https://huggingface.co/spaces/clone3/NewSpace' |
|
|
|
|
|
interval_seconds = 1800 |
|
|
|
|
|
background_thread = threading.Thread(target=background_request, args=(space_url,space_url_self, interval_seconds)) |
|
background_thread.start() |
|
|
|
|
|
def echo_text(text): |
|
return f"You said: {text}" |
|
|
|
iface = gr.Interface(fn=echo_text, inputs="text", outputs="text") |
|
iface.launch() |