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.
autoload_js_handler¶
Provide a request handler that returns a page displaying a document.
- class AutoloadJsHandler(tornado_app: BokehTornado, *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.
autoload_metadata_handler¶
Provide a request handler that returns a json with metadata information from the application
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
- get_current_user()¶
Delegate to the synchronous
get_user
method of the auth provider
- get_login_url()¶
Delegates to``get_login_url`` method of the auth provider, or the
login_url
attribute.
- async prepare()¶
Async counterpart to
get_current_user
session_handler¶
Abstract request handler that handles bokeh-session-id
- class SessionHandler(tornado_app: BokehTornado, *args, **kw)[source]¶
Implements a custom Tornado handler for document display page
- get_current_user()¶
Delegate to the synchronous
get_user
method of the auth provider
- get_login_url()¶
Delegates to``get_login_url`` method of the auth provider, or the
login_url
attribute.
- async prepare()¶
Async counterpart to
get_current_user
static_handler¶
Provide a request handler that returns a page displaying a document.
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: str) bool [source]¶
Implement a check_origin policy for Tornado to call.
The supplied origin will be compared to the Bokeh server allowlist. 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
- get_compression_options() Dict[str, Any] | None [source]¶
Override to return compression options for the connection.
If this method returns None (the default), compression will be disabled. If it returns a dict (even an empty one), it will be enabled. The contents of the dict may be used to control the following compression options:
compression_level
specifies the compression level.mem_level
specifies the amount of memory used for the internal compression state.These parameters are documented in details here: https://docs.python.org/3.6/library/zlib.html#zlib.compressobj
New in version 4.1.
Changed in version 4.5: Added
compression_level
andmem_level
.
- async on_message(fragment: str | bytes) None [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
- select_subprotocol(subprotocols: List[str]) str | None [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, orNone
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: bokeh.protocol.message.Message[Any]) None [source]¶
Send a Bokeh Server protocol message to the connected client.
- Parameters
message (Message) – a message to send