File size: 927 Bytes
88f59a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""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()