Spaces:
Sleeping
Sleeping
File size: 1,171 Bytes
e1577a5 e642a2f e1577a5 e642a2f e1577a5 e642a2f e1577a5 |
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 35 36 37 38 39 40 41 42 43 |
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() |