#----------------------------------------------------------------------------- # Copyright (c) 2012 - 2021, Anaconda, Inc., and Bokeh Contributors. # All rights reserved. # # The full license is in the file LICENSE.txt, distributed with this software. #----------------------------------------------------------------------------- ''' ''' #----------------------------------------------------------------------------- # Boilerplate #----------------------------------------------------------------------------- from __future__ import annotations import logging # isort:skip log = logging.getLogger(__name__) #----------------------------------------------------------------------------- # Imports #----------------------------------------------------------------------------- # Standard library imports from typing import TYPE_CHECKING, Dict from urllib.parse import quote_plus, urlparse # External imports from typing_extensions import Literal if TYPE_CHECKING: from jinja2 import Template # Bokeh imports from ..core.templates import AUTOLOAD_REQUEST_TAG, FILE from ..resources import DEFAULT_SERVER_HTTP_URL from ..util.serialization import make_id from ..util.string import format_docstring from .bundle import bundle_for_objs_and_resources from .elements import html_page_for_render_items from .util import RenderItem if TYPE_CHECKING: from ..core.types import ID, Unknown from ..model import Model from ..resources import Resources from ..server.session import ServerSession #----------------------------------------------------------------------------- # Globals and constants #----------------------------------------------------------------------------- __all__ = ( 'server_document', 'server_session', 'server_html_page_for_session', ) #----------------------------------------------------------------------------- # General API #----------------------------------------------------------------------------- def server_document(url: str = "default", relative_urls: bool = False, resources: Literal["default"] | None = "default", arguments: Dict[str, str] | None = None, headers: Dict[str, str] | None = None) -> str: ''' Return a script tag that embeds content from a Bokeh server. Bokeh apps embedded using these methods will NOT set the browser window title. Args: url (str, optional) : A URL to a Bokeh application on a Bokeh server (default: "default") If ``"default"`` the default URL ``{DEFAULT_SERVER_HTTP_URL}`` will be used. relative_urls (bool, optional) : Whether to use relative URLs for resources. If ``True`` the links generated for resources such a BokehJS JavaScript and CSS will be relative links. This should normally be set to ``False``, but must be set to ``True`` in situations where only relative URLs will work. E.g. when running the Bokeh behind reverse-proxies under certain configurations resources (str) : A string specifying what resources need to be loaded along with the document. If ``default`` then the default JS/CSS bokeh files will be loaded. If None then none of the resource files will be loaded. This is useful if you prefer to serve those resource files via other means (e.g. from a caching server). Be careful, however, that the resource files you'll load separately are of the same version as that of the server's, otherwise the rendering may not work correctly. arguments (dict[str, str], optional) : A dictionary of key/values to be passed as HTTP request arguments to Bokeh application code (default: None) headers (dict[str, str], optional) : A dictionary of key/values to be passed as HTTP Headers to Bokeh application code (default: None) Returns: A ``