Source code for bokeh.server.views.metadata_handler
#-----------------------------------------------------------------------------# 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 json with metadata information from the application'''#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Standard library importsimportjson# External importsfromtornado.webimportauthenticated# Bokeh importsfrom.auth_request_handlerimportAuthRequestHandlerfrom.session_handlerimportSessionHandler#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=('MetadataHandler',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------
[docs]classMetadataHandler(SessionHandler,AuthRequestHandler):''' Implements a custom Tornado handler for document display page '''@authenticatedasyncdefget(self,*args,**kwargs):url=self.application_context.urluserdata=self.application_context.application.metadataifcallable(userdata):userdata=userdata()ifuserdataisNone:userdata={}metadata=dict(url=url,data=userdata)self.set_header("Content-Type",'application/json')self.write(json.dumps(metadata))