Spaces:
Running
Running
File size: 727 Bytes
ad5656b aafc2da ad5656b | 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 | import requests
import time
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
import os
URL = os.getenv("SPACE_URL", "https://huggingface.co/spaces/Qalam/Nuclear-Intelligence")
def ping_space():
try:
response = requests.get(URL)
if response.status_code == 200:
logger.info(f"Successfully pinged {URL}")
else:
logger.warning(f"Failed to ping {URL}. Status code: {response.status_code}")
except Exception as e:
logger.error(f"Error pinging {URL}: {e}")
if __name__ == "__main__":
logger.info("Starting Keep-Alive script...")
while True:
ping_space()
time.sleep(20 * 60) # Ping every 20 minutes
|