analytics-jiten commited on
Commit
0ee63ce
·
1 Parent(s): 4f91f47

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """This files enables serving Panel apps on Hugging Face Spaces"""
2
+ import os
3
+ from subprocess import Popen
4
+
5
+ # CONFIGURE YOUR SETTINGS HERE
6
+
7
+ # Space separated list of .py or .ipynb files to serve
8
+ APPS_TO_SERVE = "pages/index.py pages/videostream.py pages/my_dashboard.py"
9
+
10
+ # Prefix of the index .py or .ipynb file. Must be in APPS_TO_SERVE too
11
+ INDEX_PAGE = "index"
12
+
13
+ # NORMALLY NO NEED TO CHANGE THE BELOW
14
+ PORT = os.environ.get("PORT", "7860")
15
+ ADDRESS = "0.0.0.0"
16
+ command = [
17
+ "panel",
18
+ "serve",
19
+ *APPS_TO_SERVE.split(" "),
20
+ "--index",
21
+ INDEX_PAGE,
22
+ "--port",
23
+ PORT,
24
+ "--address",
25
+ ADDRESS,
26
+ "--allow-websocket-origin",
27
+ "localhost",
28
+ "--allow-websocket-origin",
29
+ "*.hf.space",
30
+ "--allow-websocket-origin",
31
+ "*.huggingface.co",
32
+ # "--log-level",
33
+ # "debug"
34
+ ]
35
+ if os.name != "nt":
36
+ command = command + ["--num-procs", "4", "--num-threads", "4"]
37
+
38
+ print(" ".join(command))
39
+ worker = Popen(command)
40
+ worker.wait()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ panel
2
+ holoviews
3
+ bokeh
4
+ pandas