Show More
@@ -123,11 +123,11 b' class NotebookWebApplication(web.Application):' | |||||
123 |
|
123 | |||
124 | def __init__(self, ipython_app, kernel_manager, contents_manager, |
|
124 | def __init__(self, ipython_app, kernel_manager, contents_manager, | |
125 | cluster_manager, session_manager, kernel_spec_manager, log, |
|
125 | cluster_manager, session_manager, kernel_spec_manager, log, | |
126 | base_url, settings_overrides, jinja_env_options): |
|
126 | base_url, default_url, settings_overrides, jinja_env_options): | |
127 |
|
127 | |||
128 | settings = self.init_settings( |
|
128 | settings = self.init_settings( | |
129 | ipython_app, kernel_manager, contents_manager, cluster_manager, |
|
129 | ipython_app, kernel_manager, contents_manager, cluster_manager, | |
130 | session_manager, kernel_spec_manager, log, base_url, |
|
130 | session_manager, kernel_spec_manager, log, base_url, default_url, | |
131 | settings_overrides, jinja_env_options) |
|
131 | settings_overrides, jinja_env_options) | |
132 | handlers = self.init_handlers(settings) |
|
132 | handlers = self.init_handlers(settings) | |
133 |
|
133 | |||
@@ -135,7 +135,7 b' class NotebookWebApplication(web.Application):' | |||||
135 |
|
135 | |||
136 | def init_settings(self, ipython_app, kernel_manager, contents_manager, |
|
136 | def init_settings(self, ipython_app, kernel_manager, contents_manager, | |
137 | cluster_manager, session_manager, kernel_spec_manager, |
|
137 | cluster_manager, session_manager, kernel_spec_manager, | |
138 | log, base_url, settings_overrides, |
|
138 | log, base_url, default_url, settings_overrides, | |
139 | jinja_env_options=None): |
|
139 | jinja_env_options=None): | |
140 | # Python < 2.6.5 doesn't accept unicode keys in f(**kwargs), and |
|
140 | # Python < 2.6.5 doesn't accept unicode keys in f(**kwargs), and | |
141 | # base_url will always be unicode, which will in turn |
|
141 | # base_url will always be unicode, which will in turn | |
@@ -153,6 +153,7 b' class NotebookWebApplication(web.Application):' | |||||
153 | # basics |
|
153 | # basics | |
154 | log_function=log_request, |
|
154 | log_function=log_request, | |
155 | base_url=base_url, |
|
155 | base_url=base_url, | |
|
156 | default_url=default_url, | |||
156 | template_path=template_path, |
|
157 | template_path=template_path, | |
157 | static_path=ipython_app.static_file_path, |
|
158 | static_path=ipython_app.static_file_path, | |
158 | static_handler_class = FileFindHandler, |
|
159 | static_handler_class = FileFindHandler, | |
@@ -207,6 +208,13 b' class NotebookWebApplication(web.Application):' | |||||
207 | handlers.append( |
|
208 | handlers.append( | |
208 | (r"/nbextensions/(.*)", FileFindHandler, {'path' : settings['nbextensions_path']}), |
|
209 | (r"/nbextensions/(.*)", FileFindHandler, {'path' : settings['nbextensions_path']}), | |
209 | ) |
|
210 | ) | |
|
211 | # set the URL that will be redirected from `/` | |||
|
212 | handlers.append( | |||
|
213 | (r'/?', web.RedirectHandler, { | |||
|
214 | 'url' : url_path_join(settings['base_url'], settings['default_url']), | |||
|
215 | 'permanent': False, # want 302, not 301 | |||
|
216 | }) | |||
|
217 | ) | |||
210 | # prepend base_url onto the patterns that we match |
|
218 | # prepend base_url onto the patterns that we match | |
211 | new_handlers = [] |
|
219 | new_handlers = [] | |
212 | for handler in handlers: |
|
220 | for handler in handlers: | |
@@ -367,6 +375,10 b' class NotebookApp(BaseIPythonApplication):' | |||||
367 | help="Set the Access-Control-Allow-Credentials: true header" |
|
375 | help="Set the Access-Control-Allow-Credentials: true header" | |
368 | ) |
|
376 | ) | |
369 |
|
377 | |||
|
378 | default_url = Unicode('/tree', config=True, | |||
|
379 | help="The default URL to redirect to from `/`" | |||
|
380 | ) | |||
|
381 | ||||
370 | ip = Unicode('localhost', config=True, |
|
382 | ip = Unicode('localhost', config=True, | |
371 | help="The IP address the notebook server will listen on." |
|
383 | help="The IP address the notebook server will listen on." | |
372 | ) |
|
384 | ) | |
@@ -692,7 +704,7 b' class NotebookApp(BaseIPythonApplication):' | |||||
692 | self.web_app = NotebookWebApplication( |
|
704 | self.web_app = NotebookWebApplication( | |
693 | self, self.kernel_manager, self.contents_manager, |
|
705 | self, self.kernel_manager, self.contents_manager, | |
694 | self.cluster_manager, self.session_manager, self.kernel_spec_manager, |
|
706 | self.cluster_manager, self.session_manager, self.kernel_spec_manager, | |
695 | self.log, self.base_url, self.webapp_settings, |
|
707 | self.log, self.base_url, self.default_url, self.webapp_settings, | |
696 | self.jinja_environment_options |
|
708 | self.jinja_environment_options | |
697 | ) |
|
709 | ) | |
698 | if self.certfile: |
|
710 | if self.certfile: |
@@ -59,18 +59,6 b' class TreeHandler(IPythonHandler):' | |||||
59 | )) |
|
59 | )) | |
60 |
|
60 | |||
61 |
|
61 | |||
62 | class TreeRedirectHandler(IPythonHandler): |
|
|||
63 | """Redirect a request to the corresponding tree URL""" |
|
|||
64 |
|
||||
65 | @web.authenticated |
|
|||
66 | def get(self, path=''): |
|
|||
67 | url = url_escape(url_path_join( |
|
|||
68 | self.base_url, 'tree', path.strip('/') |
|
|||
69 | )) |
|
|||
70 | self.log.debug("Redirecting %s to %s", self.request.path, url) |
|
|||
71 | self.redirect(url) |
|
|||
72 |
|
||||
73 |
|
||||
74 | #----------------------------------------------------------------------------- |
|
62 | #----------------------------------------------------------------------------- | |
75 | # URL to handler mappings |
|
63 | # URL to handler mappings | |
76 | #----------------------------------------------------------------------------- |
|
64 | #----------------------------------------------------------------------------- | |
@@ -80,5 +68,4 b' default_handlers = [' | |||||
80 | (r"/tree%s" % notebook_path_regex, TreeHandler), |
|
68 | (r"/tree%s" % notebook_path_regex, TreeHandler), | |
81 | (r"/tree%s" % path_regex, TreeHandler), |
|
69 | (r"/tree%s" % path_regex, TreeHandler), | |
82 | (r"/tree", TreeHandler), |
|
70 | (r"/tree", TreeHandler), | |
83 | (r"/?", TreeRedirectHandler), |
|
|||
84 | ] |
|
71 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now