Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
holoviz
GitHub Repository: holoviz/panel
Path: blob/main/binder/jupyter-panel-apps-server/jupyter_panel_apps_server.py
2012 views
1
"""
2
Function to configure serving the panel example apps via jupyter-server-proxy.
3
"""
4
import pathlib
5
6
from glob import glob
7
8
ICON_PATH = str((pathlib.Path(__file__).parent / "examples-icon.svg").absolute())
9
10
DONT_SERVE = [
11
"examples/gallery/demos/attractors.ipynb",
12
"examples/gallery/demos/gapminders.ipynb",
13
"examples/gallery/demos/glaciers.ipynb",
14
"examples/gallery/demos/nyc_taxi.ipynb",
15
"examples/gallery/demos/portfolio-optimizer.ipynb",
16
]
17
18
19
def get_apps():
20
return [
21
app
22
for app in glob("examples/gallery/**/*.ipynb", recursive=True)
23
if app not in DONT_SERVE
24
]
25
26
27
def panel_serve_examples():
28
"""Returns the jupyter-server-proxy configuration for serving the example notebooks as Panel
29
apps.
30
31
Returns:
32
Dict: The configuration dictionary
33
"""
34
apps = get_apps()
35
# See:
36
# https://jupyter-server-proxy.readthedocs.io/en/latest/server-process.html
37
# https://github.com/holoviz/jupyter-panel-proxy/blob/main/panel_server/__init__.py
38
return {
39
"command": [
40
"panel",
41
"serve",
42
*apps,
43
"--allow-websocket-origin=*",
44
"--port",
45
"{port}",
46
"--prefix",
47
"{base_url}panel",
48
],
49
"absolute_url": True,
50
"timeout": 360,
51
"launcher_entry": {
52
"enabled": True,
53
"title": "Apps",
54
"icon_path": ICON_PATH,
55
},
56
}
57
58