WebsoketSend / app.py
clone3's picture
Update app.py
e642a2f
raw
history blame
1.17 kB
import gradio as gr
import requests
import threading
import time
def send_dummy_request(space_url):
try:
response = requests.get(space_url)
# Print the response status code (optional)
print(f"Response Status Code: {response.status_code}")
except Exception as e:
print(f"Error: {e}")
def create_interface():
# Replace 'YOUR_SPACE_URL' with the actual URL of your deployed Hugging Face Space
space_url = 'YOUR_SPACE_URL'
# Set the interval for sending requests (in seconds)
interval_seconds = 1800 # 30 minutes
# Define the Gradio interface components
iface = gr.Interface(
fn=send_dummy_request,
args=["space_url"],
inputs=gr.Textbox(text=space_url, label="Space URL"),
outputs=None,
live=True,
)
# Start a thread for periodic dummy requests
def periodic_requests():
while True:
send_dummy_request(space_url)
time.sleep(interval_seconds)
thread = threading.Thread(target=periodic_requests)
thread.start()
# Launch the Gradio interface
iface.launch()
if __name__ == "__main__":
create_interface()