##// END OF EJS Templates
Load the utils module
Load the utils module

File last commit:

r18758:8ab80d68
r18892:507cf2e8
Show More
handlers.py
49 lines | 1.4 KiB | text/x-python | PythonLexer
MinRK
move `/files/` redirect to base handlers...
r17533 """Tornado handlers for the live notebook view."""
Brian E. Granger
Adding new files.
r10641
MinRK
move `/files/` redirect to base handlers...
r17533 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Brian E. Granger
Adding new files.
r10641
MinRK
support 1.0-style `files/` relative URLs...
r13563 import os
Brian E. Granger
Adding new files.
r10641 from tornado import web
Brian E. Granger
Splitting handlers into different files....
r10642 HTTPError = web.HTTPError
Brian E. Granger
Adding new files.
r10641
MinRK
move `/files/` redirect to base handlers...
r17533 from ..base.handlers import (
IPythonHandler, FilesRedirectHandler,
notebook_path_regex, path_regex,
)
from ..utils import url_escape
Brian E. Granger
Adding new files.
r10641
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016 class NotebookHandler(IPythonHandler):
Brian E. Granger
Adding new files.
r10641
@web.authenticated
Min RK
address review in contents service...
r18758 def get(self, path):
Paul Ivanov
named_notebook_path: consistent usage convention
r13029 """get renders the notebook template if a name is given, or
redirects to the '/files/' handler if the name is not given."""
MinRK
strip '/' from paths in template-render handlers
r13117 path = path.strip('/')
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073
MinRK
adjust definition of 'path' in notebooks...
r13067 # a .ipynb filename was given
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 if not cm.file_exists(path):
raise web.HTTPError(404, u'Notebook does not exist: %s' % path)
name = url_escape(path.rsplit('/', 1)[-1])
MinRK
move url_[un]escape to utils from nbm
r13068 path = url_escape(path)
MinRK
adjust definition of 'path' in notebooks...
r13067 self.write(self.render_template('notebook.html',
notebook_path=path,
notebook_name=name,
kill_kernel=False,
mathjax_url=self.mathjax_url,
)
)
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016
Brian E. Granger
Adding new files.
r10641
Brian E. Granger
More work on the handlers
r10647 #-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
default_handlers = [
Thomas Kluyver
Move notebook URL fragment regexen into IPython.html.base.handlers
r13916 (r"/notebooks%s" % notebook_path_regex, NotebookHandler),
MinRK
move `/files/` redirect to base handlers...
r17533 (r"/notebooks%s" % path_regex, FilesRedirectHandler),
Zachary Sailer
fixing broken links from recent changes....
r13033 ]