mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
use NotebookManager APIs in nbconvert handler
This commit is contained in:
parent
cb25736a24
commit
f9e8824fef
@ -76,15 +76,12 @@ class NbconvertFileHandler(IPythonHandler):
|
|||||||
exporter = get_exporter(format, config=self.config)
|
exporter = get_exporter(format, config=self.config)
|
||||||
|
|
||||||
path = path.strip('/')
|
path = path.strip('/')
|
||||||
os_path = self.notebook_manager.get_os_path(name, path)
|
model = self.notebook_manager.get_notebook(name=name, path=path)
|
||||||
if not os.path.isfile(os_path):
|
|
||||||
raise web.HTTPError(404, u'Notebook does not exist: %s' % name)
|
|
||||||
|
|
||||||
info = os.stat(os_path)
|
self.set_header('Last-Modified', model['last_modified'])
|
||||||
self.set_header('Last-Modified', tz.utcfromtimestamp(info.st_mtime))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
output, resources = exporter.from_filename(os_path)
|
output, resources = exporter.from_notebook_node(model['content'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise web.HTTPError(500, "nbconvert failed: %s" % e)
|
raise web.HTTPError(500, "nbconvert failed: %s" % e)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user