Skip to content

Commit 18455ec

Browse files
committed
move static content behind base_url
1 parent 321588d commit 18455ec

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

jupyter_server/extension/handler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExtensionHandlerMixin:
1515
"""Base class for Jupyter server extension handlers.
1616
1717
Subclasses can serve static files behind a namespaced
18-
endpoint: "/static/<name>/"
18+
endpoint: "<base_url>/static/<name>/"
1919
2020
This allows multiple extensions to serve static files under
2121
their own namespace and avoid intercepting requests for
@@ -49,9 +49,16 @@ def config(self):
4949
def server_config(self):
5050
return self.settings["config"]
5151

52+
@property
53+
def base_url(self):
54+
return self.settings.get('base_url', '/')
55+
5256
@property
5357
def static_url_prefix(self):
54-
return "/static/{name}/".format(name=self.name)
58+
return "{base_url}/static/{name}/".format(
59+
name=self.name,
60+
base_url=self.base_url
61+
)
5562

5663
@property
5764
def static_path(self):

jupyter_server/extension/serverextension.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _get_config_dir(user=False, sys_prefix=False):
4545
return extdir
4646

4747

48-
def _get_extmanager_for_context(user=False, sys_prefix=False):
48+
def _get_extmanager_for_context(write_dir="jupyter_server_config.d", user=False, sys_prefix=False):
4949
"""Get an extension manager pointing at the current context
5050
5151
Returns the path to the current context and an ExtensionManager object.
@@ -295,6 +295,8 @@ def list_server_extensions(self):
295295
{"user": False, "sys_prefix": True},
296296
{"user": False, "sys_prefix": False}
297297
)
298+
self.log.info
299+
298300
for option in configurations:
299301
config_dir, ext_manager = _get_extmanager_for_context(**option)
300302
self.log.info("Config dir: {}".format(config_dir))

0 commit comments

Comments
 (0)