예제 #1
0
    def initialize_handlers(self):
        """Load the (URL pattern, handler) tuples for each component."""
        # Order matters. The first handler to match the URL will handle the request.
        handlers = []
        # load extra services specified by users before default handlers
        for service in self.settings['extra_services']:
            handlers.extend(load_handlers(service))

        handlers.extend(load_handlers('nbclassic.tree.handlers'))
        handlers.extend(load_handlers('nbclassic.notebook.handlers'))

        handlers.append(
            (r"/nbextensions/(.*)", FileFindHandler, {
                'path': self.settings['nbextensions_path'],
                'no_cache_paths': ['/'], # don't cache anything in nbextensions
            }),
        )
        handlers.append(
            (r"/custom/(.*)", FileFindHandler, {
                'path': self.settings['static_custom_path'],
                'no_cache_paths': ['/'], # don't cache anything in nbextensions
            }),
        )
        # Add new handlers to Jupyter server handlers.
        self.handlers.extend(handlers)
예제 #2
0
    def initialize_handlers(self):
        """Load the (URL pattern, handler) tuples for each component."""
        # Order matters. The first handler to match the URL will handle the request.
        handlers = []

        # Add a redirect from /notebooks to /edit
        # for opening non-ipynb files in edit mode.
        handlers.append((rf"/{self.file_url_prefix}/((?!.*\.ipynb($|\?)).*)",
                         RedirectHandler, {
                             "url": "/edit/{0}"
                         }))

        # load extra services specified by users before default handlers
        for service in self.settings['extra_services']:
            handlers.extend(load_handlers(service))

        handlers.extend(load_handlers('nbclassic.tree.handlers'))
        handlers.extend(load_handlers('nbclassic.notebook.handlers'))
        handlers.extend(load_handlers('nbclassic.edit.handlers'))

        # Add terminal handlers
        handlers.append((r"/terminals/(\w+)", TerminalHandler))

        handlers.append(
            (
                r"/nbextensions/(.*)",
                FileFindHandler,
                {
                    'path': self.settings['nbextensions_path'],
                    'no_cache_paths':
                    ['/'],  # don't cache anything in nbextensions
                }), )
        handlers.append(
            (
                r"/custom/(.*)",
                FileFindHandler,
                {
                    'path': self.settings['static_custom_path'],
                    'no_cache_paths':
                    ['/'],  # don't cache anything in nbextensions
                }), )
        # Add new handlers to Jupyter server handlers.
        self.handlers.extend(handlers)
예제 #3
0
    def initialize_handlers(self):
        """Load the (URL pattern, handler) tuples for each component."""
        # Order matters. The first handler to match the URL will handle the request.
        handlers = []
        # load extra services specified by users before default handlers
        for service in self.settings['extra_services']:
            handlers.extend(load_handlers(service))

        handlers.extend(load_handlers('nbclassic.tree.handlers'))
        handlers.extend(load_handlers('nbclassic.notebook.handlers'))
        handlers.extend(load_handlers('nbclassic.edit.handlers'))

        # Add terminal handlers
        try:
            term_mgr = self.serverapp.web_app.settings['terminal_manager']
        except KeyError:
            pass  # Terminals not enabled
        else:
            handlers.append((r"/terminals/(\w+)", TerminalHandler))
            handlers.append((r"/terminals/websocket/(\w+)", TermSocket, {
                'term_manager': term_mgr
            }))

        handlers.append(
            (
                r"/nbextensions/(.*)",
                FileFindHandler,
                {
                    'path': self.settings['nbextensions_path'],
                    'no_cache_paths':
                    ['/'],  # don't cache anything in nbextensions
                }), )
        handlers.append(
            (
                r"/custom/(.*)",
                FileFindHandler,
                {
                    'path': self.settings['static_custom_path'],
                    'no_cache_paths':
                    ['/'],  # don't cache anything in nbextensions
                }), )
        # Add new handlers to Jupyter server handlers.
        self.handlers.extend(handlers)