Spaces:
Runtime error
Runtime error
"""This files enables serving Panel apps on Hugging Face Spaces""" | |
import os | |
from subprocess import Popen | |
# CONFIGURE YOUR SETTINGS HERE | |
# Space separated list of .py or .ipynb files to serve | |
APPS_TO_SERVE = "secretlanguage.py" | |
# Prefix of the index .py or .ipynb file. Must be in APPS_TO_SERVE too | |
INDEX_PAGE = "secretlanguage" | |
# NORMALLY NO NEED TO CHANGE THE BELOW | |
PORT = os.environ.get("PORT", "7860") | |
ADDRESS = "0.0.0.0" | |
command = [ | |
"panel", | |
"serve", | |
*APPS_TO_SERVE.split(" "), | |
"--index", | |
INDEX_PAGE, | |
"--port", | |
PORT, | |
"--address", | |
ADDRESS, | |
"--allow-websocket-origin", | |
"localhost", | |
"--allow-websocket-origin", | |
"*.hf.space", | |
"--allow-websocket-origin", | |
"*.huggingface.co", | |
# "--log-level", | |
# "debug" | |
] | |
if os.name != "nt": | |
command = command + ["--num-procs", "4", "--num-threads", "4"] | |
print(" ".join(command)) | |
worker = Popen(command) | |
worker.wait() |