Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,47 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import threading
|
3 |
+
import requests
|
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 Of Wait: {response.status_code}")
|
11 |
+
except Exception as e:
|
12 |
+
print(f"Error: {e}")
|
13 |
|
14 |
+
def send_dummy_request_self(space_url_self):
|
15 |
+
try:
|
16 |
+
response = requests.get(space_url_self)
|
17 |
+
# Print the response status code (optional)
|
18 |
+
print(f"Response Status Code Of Self: {response.status_code}")
|
19 |
+
except Exception as e:
|
20 |
+
print(f"Error: {e}")
|
21 |
+
|
22 |
+
def background_request(space_url,space_url_self, interval_seconds):
|
23 |
+
try:
|
24 |
+
while True:
|
25 |
+
send_dummy_request(space_url)
|
26 |
+
send_dummy_request_self(space_url_self)
|
27 |
+
time.sleep(interval_seconds)
|
28 |
+
except KeyboardInterrupt:
|
29 |
+
print("Background script terminated by user.")
|
30 |
+
|
31 |
+
# Replace 'YOUR_SPACE_URL' with the actual URL of your deployed Hugging Face Space
|
32 |
+
space_url = 'https://huggingface.co/spaces/clone3/Wait'
|
33 |
+
space_url_self = 'https://huggingface.co/spaces/clone3/Sender'
|
34 |
+
|
35 |
+
# Set the interval for sending requests (in seconds)
|
36 |
+
interval_seconds = 1800 # 30 minutes
|
37 |
+
|
38 |
+
# Start the background thread
|
39 |
+
background_thread = threading.Thread(target=background_request, args=(space_url,space_url_self, interval_seconds))
|
40 |
+
background_thread.start()
|
41 |
+
|
42 |
+
# Gradio interface
|
43 |
+
def echo_text(text):
|
44 |
+
return f"You said: {text}"
|
45 |
+
|
46 |
+
iface = gr.Interface(fn=echo_text, inputs="text", outputs="text")
|
47 |
iface.launch()
|