File: handlers.py

package info (click to toggle)
jupyter-notebook 4.2.3-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,800 kB
  • ctags: 2,454
  • sloc: python: 8,698; makefile: 240; sh: 74
file content (25 lines) | stat: -rw-r--r-- 656 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json

from tornado import web

from ...base.handlers import APIHandler, json_errors

class NbconvertRootHandler(APIHandler):

    @web.authenticated
    @json_errors
    def get(self):
        try:
            from nbconvert.exporters.export import exporter_map
        except ImportError as e:
            raise web.HTTPError(500, "Could not import nbconvert: %s" % e)
        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),
]