mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
91d3326923
catches import / key errors and turns them into proper http errors
26 lines
622 B
Python
26 lines
622 B
Python
import json
|
|
|
|
from tornado import web
|
|
|
|
from ...base.handlers import IPythonHandler, json_errors
|
|
try:
|
|
from IPython.nbconvert.exporters.export import exporter_map
|
|
except ImportError:
|
|
exporter_map = {}
|
|
|
|
class NbconvertRootHandler(IPythonHandler):
|
|
SUPPORTED_METHODS = ('GET',)
|
|
|
|
@web.authenticated
|
|
@json_errors
|
|
def get(self):
|
|
res = {}
|
|
for format, exporter in exporter_map.items():
|
|
res[format] = info = {}
|
|
info['output_mimetype'] = exporter.output_mimetype
|
|
|
|
self.finish(json.dumps(res))
|
|
|
|
default_handlers = [
|
|
(r"/api/nbconvert", NbconvertRootHandler),
|
|
] |