Skip to content

Commit

Permalink
Merge pull request voila-dashboards#73 from SylvainCorlay/fixup-jupyt…
Browse files Browse the repository at this point in the history
…er_server-extensions

Fixing up jupyter server extension
  • Loading branch information
SylvainCorlay authored Mar 7, 2019
2 parents ae1c2e7 + 175c882 commit a7b6894
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions voila/server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from jupyter_server.base.handlers import path_regex
from jupyter_server.base.handlers import FileFindHandler

from .paths import ROOT, STATIC_ROOT, collect_template_paths
from .paths import ROOT, STATIC_ROOT, collect_template_paths, jupyter_path
from .handler import VoilaHandler
from .treehandler import VoilaTreeHandler
from .static_file_handler import MultiStaticFileHandler
Expand Down Expand Up @@ -44,6 +44,12 @@ def load_jupyter_server_extension(server_app):

host_pattern = '.*$'
base_url = url_path_join(web_app.settings['base_url'])
# First look into 'nbextensions_path' configuration key (classic notebook)
# and fall back to default path for nbextensions (jupyter server).
if 'nbextensions_path' in web_app.settings:
nbextensions_path = web_app.settings['nbextensions_path']
else:
nbextensions_path = jupyter_path('nbextensions')
web_app.add_handlers(host_pattern, [
(url_path_join(base_url, '/voila/render' + path_regex), VoilaHandler, {
'config': server_app.config,
Expand All @@ -57,7 +63,7 @@ def load_jupyter_server_extension(server_app):
url_path_join(base_url, r'/voila/nbextensions/(.*)'),
FileFindHandler,
{
'path': web_app.settings['nbextensions_path'],
'path': nbextensions_path,
'no_cache_paths': ['/'], # don't cache anything in nbextensions
},
)
Expand Down

0 comments on commit a7b6894

Please sign in to comment.