File size: 1,678 Bytes
1c7c3ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7327f59
 
 
 
 
 
 
 
 
 
 
1c7c3ea
7327f59
1c7c3ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
import gradio as gr
import threading
import requests
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 Of Wait: {response.status_code}")
    except Exception as e:
        print(f"Error: {e}")

def background_request(space_urls, interval_seconds):
    try:
        while True:
            for space_url in space_urls:
                send_dummy_request(space_url)
            time.sleep(interval_seconds)
    except KeyboardInterrupt:
        print("Background script terminated by user.")


space_urls = [
    # For Spaces
    'https://huggingface.co/spaces/GenieLamp/Image0',
    'https://huggingface.co/spaces/GenieLamp/Image1',
    'https://huggingface.co/spaces/GenieLamp/Image2',
    'https://huggingface.co/spaces/GenieLamp/Image3',
    'https://huggingface.co/spaces/GenieLamp/Image4',
    'https://huggingface.co/spaces/GenieLamp/Image5',
    'https://huggingface.co/spaces/GenieLamp/Image6',
    'https://huggingface.co/spaces/GenieLamp/Image7',
    'https://huggingface.co/spaces/GenieLamp/Image8',
    'https://huggingface.co/spaces/GenieLamp/Image9',
    
    # For Self
    'https://huggingface.co/spaces/GenieLamp/Alive',
]

# Set the interval for sending requests (in seconds)
interval_seconds = 7200  # 2 hours

# Start the background thread
background_thread = threading.Thread(target=background_request, args=(space_urls, interval_seconds))
background_thread.start()

# Gradio interface
def echo_text(text):
    return f"You said: {text}"

iface = gr.Interface(fn=echo_text, inputs="text", outputs="text")
iface.launch()