bokeh.server.views#
auth_request_handler#
Provide a mixin class to add authorization hooks to a request handler.
- class AuthRequestHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)[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.
- class DocHandler(tornado_app: BokehTornado, *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: BokehTornado, *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.
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
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.