Spaces:
Sleeping
Sleeping
Download app.py from SMUCox/PLP-Draft3: direct link, hf CLI and curl.
- Browser
- Download file 843 Bytes
-
https://huggingface.co/spaces/SMUCox/PLP-Draft3/resolve/main/app.py
- Command line
-
hf download hf://spaces/SMUCox/PLP-Draft3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SMUCox/PLP-Draft3/resolve/main/app.py
843 Bytes
| import os | |
| import base64 | |
| import threading | |
| import time | |
| import urllib.request | |
| # Keep-alive functionality | |
| def keep_alive(): | |
| space_host = os.environ.get("SPACE_HOST", "") | |
| if space_host: | |
| ping_url = f"https://{space_host}" | |
| while True: | |
| try: | |
| urllib.request.urlopen(ping_url, timeout=10) | |
| print(f"[Keep-Alive] Pinged at {time.strftime('%H:%M:%S')}") | |
| except: | |
| pass | |
| time.sleep(600) | |
| threading.Thread(target=keep_alive, daemon=True).start() | |
| # Load and run the main code | |
| main_code = os.environ.get("MAIN_CODE", "") | |
| if not main_code: | |
| print("ERROR: MAIN_CODE secret not found!") | |
| print("Please add the MAIN_CODE secret in Hugging Face Space settings.") | |
| else: | |
| decoded_code = base64.b64decode(main_code).decode('utf-8') | |
| exec(decoded_code) |