clone3 commited on
Commit
e1577a5
·
1 Parent(s): 1765494

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import threading
4
+ import time
5
+
6
+ def send_dummy_request(space_url):
7
+ try:
8
+ response = requests.get(space_url)
9
+ # Print the response status code (optional)
10
+ print(f"Response Status Code: {response.status_code}")
11
+ except Exception as e:
12
+ print(f"Error: {e}")
13
+
14
+ def create_interface():
15
+ # Replace 'YOUR_SPACE_URL' with the actual URL of your deployed Hugging Face Space
16
+ space_url = 'YOUR_SPACE_URL'
17
+
18
+ # Set the interval for sending requests (in seconds)
19
+ interval_seconds = 1800 # 30 minutes
20
+
21
+ # Define the interface components
22
+ def dummy_request():
23
+ send_dummy_request(space_url)
24
+
25
+ # Create the Gradio interface
26
+ iface = gr.Interface(
27
+ fn=dummy_request,
28
+ live=True,
29
+ capture_session=True
30
+ )
31
+
32
+ # Start a thread for periodic dummy requests
33
+ def periodic_requests():
34
+ while True:
35
+ dummy_request()
36
+ time.sleep(interval_seconds)
37
+
38
+ thread = threading.Thread(target=periodic_requests)
39
+ thread.start()
40
+
41
+ # Launch the Gradio interface
42
+ iface.launch()
43
+
44
+ if __name__ == "__main__":
45
+ create_interface()