##// END OF EJS Templates
Merge pull request #6706 from jhamrick/display-prompt-numbers...
Merge pull request #6706 from jhamrick/display-prompt-numbers Correctly display prompt numbers that are 'None'

File last commit:

r17538:53182995
r18350:ecca4c58 merge
Show More
handlers.py
51 lines | 1.5 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
MinRK
adjust definition of 'path' in notebooks...
r13067 def get(self, path='', name=None):
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
adjust definition of 'path' in notebooks...
r13067 if name is None:
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073 raise web.HTTPError(500, "This shouldn't be accessible: %s" % self.request.uri)
MinRK
adjust definition of 'path' in notebooks...
r13067 # a .ipynb filename was given
MinRK
rename notebooks service to contents service...
r17524 if not cm.file_exists(name, path):
MinRK
adjust definition of 'path' in notebooks...
r13067 raise web.HTTPError(404, u'Notebook does not exist: %s/%s' % (path, name))
MinRK
move url_[un]escape to utils from nbm
r13068 name = url_escape(name)
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 ]