#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------''' Provide a request handler that returns a page displaying a document.'''#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# External importsfromtornado.webimportauthenticated# Bokeh importsfrombokeh.embed.serverimportserver_html_page_for_session# Bokeh importsfrom.session_handlerimportSessionHandler#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=('DocHandler',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------
[docs]classDocHandler(SessionHandler):''' Implements a custom Tornado handler for document display page '''@authenticatedasyncdefget(self,*args,**kwargs):session=awaitself.get_session()page=server_html_page_for_session(session,resources=self.application.resources(),title=session.document.title,template=session.document.template,template_variables=session.document.template_variables)self.set_header("Content-Type",'text/html')self.write(page)