bokeh.server.views

auth_mixin

Provide a mixin class to add authorization hooks to a request handler.

class AuthMixin[source]

This mixin adds the expected Tornado authorization hooks:

  • get_login_url

  • get_current_user

  • prepare

All of these delegate to the a AuthProvider confiured on the Bokeh tornado application.

get_current_user()[source]

Delegate to the synchronous get_user method of the auth provider

get_login_url()[source]

Delegates to``get_login_url`` method of the auth provider, or the login_url attribute.

prepare()[source]

Async counterpart to get_current_user

autoload_js_handler

Provide a request handler that returns a page displaying a document.

class AutoloadJsHandler(tornado_app, *args, **kw)[source]

Implements a custom Tornado handler for the autoload JS chunk

async options(*args, **kwargs)[source]

Browsers make OPTIONS requests under the hood before a GET request

set_default_headers()[source]

Override this to set HTTP headers at the beginning of the request.

For example, this is the place to set a custom Server header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling.

doc_handler

Provide a request handler that returns a page displaying a document.

class DocHandler(tornado_app, *args, **kw)[source]

Implements a custom Tornado handler for document display page

autoload_metadata_handler

Provide a request handler that returns a json with metadata information from the application

class MetadataHandler(tornado_app, *args, **kw)[source]

Implements a custom Tornado handler for document display page

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.

class RootHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)[source]

Implements a custom Tornado handler to display the available applications If only one application it redirects to that application route

session_handler

Abstract request handler that handles bokeh-session-id

class SessionHandler(tornado_app, *args, **kw)[source]

Implements a custom Tornado handler for document display page

static_handler

Provide a request handler that returns a page displaying a document.

class StaticHandler(tornado_app, *args, **kw)[source]

Implements a custom Tornado static file handler for BokehJS JavaScript and CSS resources.

ws

Provide a web socket handler for the Bokeh Server application.

class WSHandler(tornado_app, *args, **kw)[source]

Implements a custom Tornado WebSocketHandler for the Bokeh Server.

check_origin(origin)[source]

Implement a check_origin policy for Tornado to call.

The supplied origin will be compared to the Bokeh server whitelist. If the origin is not allow, an error will be logged and False will be returned.

Parameters

origin (str) – The URL of the connection origin

Returns

bool, True if the connection is allowed, False otherwise

on_close()[source]

Clean up when the connection is closed.

async on_message(fragment)[source]

Process an individual wire protocol fragment.

The websocket RFC specifies opcodes for distinguishing text frames from binary frames. Tornado passes us either a text or binary string depending on that opcode, we have to look at the type of the fragment to see what we got.

Parameters

fragment (unicode or bytes) – wire fragment to process

on_pong(data)[source]

Invoked when the response to a ping frame is received.

open()[source]

Initialize a connection to a client.

Returns

None

select_subprotocol(subprotocols)[source]

Override to implement subprotocol negotiation.

subprotocols is a list of strings identifying the subprotocols proposed by the client. This method may be overridden to return one of those strings to select it, or None to not select a subprotocol.

Failure to select a subprotocol does not automatically abort the connection, although clients may close the connection if none of their proposed subprotocols was selected.

The list may be empty, in which case this method must return None. This method is always called exactly once even if no subprotocols were proposed so that the handler can be advised of this fact.

Changed in version 5.1: Previously, this method was called with a list containing an empty string instead of an empty list if no subprotocols were proposed by the client.

async send_message(message)[source]

Send a Bokeh Server protocol message to the connected client.

Parameters

message (Message) – a message to send

async write_message(message, binary=False, locked=True)[source]

Override parent write_message with a version that acquires a write lock before writing.