This docs on this page refers to a PREVIOUS VERSION. For the latest stable release, go to https://docs.bokeh.org/

Archived docs for versions <= 1.0.4 have had to be modified from their original published configuration, and may be missing some features (e.g. source listing)

All users are encourage to update to version 1.1 or later, as soon as they are able.

bokeh.server.views.root_handler — Bokeh 1.0.2 documentation

Source code for bokeh.server.views.root_handler

''' Provide a Request handler that lists the application (if more than one)
or (if only one) redirects to the route of that applications.

'''
from __future__ import absolute_import, print_function

import logging
log = logging.getLogger(__name__)

from tornado import gen

from tornado.web import RequestHandler

[docs]class RootHandler(RequestHandler): ''' Implements a custom Tornado handler to display the available applications If only one application it redirects to that application route '''
[docs] def initialize(self, *args, **kw): self.applications = kw["applications"] self.prefix = kw["prefix"] self.use_redirect = kw["use_redirect"]
@gen.coroutine def get(self, *args, **kwargs): prefix = "" if self.prefix is None else self.prefix if self.use_redirect and len(self.applications) == 1: app_names = list(self.applications.keys()) redirect_to = prefix + app_names[0] self.redirect(redirect_to) else: self.render("app_index.html", prefix=prefix, items=sorted(self.applications.keys()))