File size: 969 Bytes
71128e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import requests
import time

st.title("Heartbeat Script to Keep Spaces Awake")

# URLs of the target Space and itself
target_space_url = "https://EzekielMW-test3.hf.space/"
self_space_url = "https://EzekielMW-activateTest3.hf.space/"

# Define the interval (in seconds) - 3 hours
interval = 3 * 60 * 60

st.write(f"Sending requests every 3 hours to: {target_space_url} and {self_space_url}")

while True:
    try:
        # Send a GET request to the root of the target Space
        target_response = requests.get(target_space_url)
        st.write(f"Request sent to target! Status code: {target_response.status_code}")
        
        # Send a GET request to itself
        self_response = requests.get(self_space_url)
        st.write(f"Request sent to self! Status code: {self_response.status_code}")

    except Exception as e:
        st.write(f"An error occurred: {e}")
    
    # Sleep for the interval (3 hours)
    time.sleep(interval)