Skip to content

Commit

Permalink
Merge pull request voila-dashboards#191 from martinRenou/fix_notebook…
Browse files Browse the repository at this point in the history
…_regex

Only use VoilaHandler for .ipynb files
  • Loading branch information
SylvainCorlay committed Jun 12, 2019
2 parents 7ac5fcf + ba061ff commit 50b199e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions voila/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@

from jupyter_server.services.kernels.kernelmanager import MappingKernelManager
from jupyter_server.services.kernels.handlers import KernelHandler, ZMQChannelsHandler
from jupyter_server.base.handlers import path_regex
from jupyter_server.services.contents.largefilemanager import LargeFileManager
from jupyter_server.base.handlers import path_regex
from jupyter_server.utils import url_path_join
from jupyter_server.services.config import ConfigManager
from jupyter_server.base.handlers import FileFindHandler
from jupyter_core.paths import jupyter_config_path, jupyter_path
from ipython_genutils.py3compat import getcwd

from .paths import ROOT, STATIC_ROOT, collect_template_paths
from .paths import ROOT, STATIC_ROOT, collect_template_paths, notebook_path_regex
from .handler import VoilaHandler
from .treehandler import VoilaTreeHandler
from ._version import __version__
Expand Down Expand Up @@ -439,7 +439,7 @@ def start(self):
handlers.extend([
(self.server_url, VoilaTreeHandler),
(url_path_join(self.server_url, r'/voila/tree' + path_regex), VoilaTreeHandler),
(url_path_join(self.server_url, r'/voila/render' + path_regex), VoilaHandler,
(url_path_join(self.server_url, r'/voila/render' + notebook_path_regex), VoilaHandler,
{
'nbconvert_template_paths': self.nbconvert_template_paths,
'config': self.config,
Expand Down
2 changes: 2 additions & 0 deletions voila/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# if the directory above us contains the following paths, it means we are installed in dev mode (pip install -e .)
DEV_MODE = os.path.exists(os.path.join(ROOT, '../setup.py')) and os.path.exists(os.path.join(ROOT, '../share'))

notebook_path_regex = r'(.*\.ipynb)'


def collect_template_paths(
nbconvert_template_paths,
Expand Down
4 changes: 2 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, jupyter_path
from .paths import ROOT, STATIC_ROOT, collect_template_paths, jupyter_path, notebook_path_regex
from .handler import VoilaHandler
from .treehandler import VoilaTreeHandler
from .static_file_handler import MultiStaticFileHandler
Expand Down Expand Up @@ -49,7 +49,7 @@ def load_jupyter_server_extension(server_app):
base_url = url_path_join(web_app.settings['base_url'])

web_app.add_handlers(host_pattern, [
(url_path_join(base_url, '/voila/render' + path_regex), VoilaHandler, {
(url_path_join(base_url, '/voila/render' + notebook_path_regex), VoilaHandler, {
'config': server_app.config,
'nbconvert_template_paths': nbconvert_template_paths,
'voila_configuration': voila_configuration
Expand Down

0 comments on commit 50b199e

Please sign in to comment.