class_docstr: A high level convenience class to run a Bokeh server.
  
  This class can automatically coordinate the three the base level
  components required to run a Bokeh server:
  
  * A Tornado ``IOLoop`` to run the Bokeh server machinery.
  
  * a ``BokehTornado`` Tornado application that defines the Bokeh server
    machinery.
  
  * a Tornado ``HTTPServer`` to direct HTTP requests
  
  This high level ``Server`` class has some limitations. In particular, it is
  not possible to set an explicit ``io_loop`` and ``num_procs`` other than 1
  at the same time. To do that, it is necessary to use ``BaseServer`` and
  coordinate the three components above explicitly.
docstr: Create a ``Server`` instance.
  
  Args:
      applications (dict[str, Application] or Application or callable) :
          A mapping from URL paths to Application instances, or a single
          Application to put at the root URL.
  
          The Application is a factory for Documents, with a new Document
          initialized for each Session. Each application is identified
          by a path that corresponds to a URL, like "/" or "/myapp"
  
          If a single Application is provided, it is mapped to the URL
          path "/" automatically.
  
          As a convenience, a callable may also be provided, in which
          an Application will be created for it using
          ``FunctionHandler``.
  
      io_loop (IOLoop, optional) :
          An explicit Tornado ``IOLoop`` to run Bokeh Server code on. If
          None, ``IOLoop.current()`` will be used (default: None)
  
      http_server_kwargs (dict, optional) :
          Extra arguments passed to ``tornado.httpserver.HTTPServer``.
  
          E.g. ``max_buffer_size`` to specify the maximum upload size.
          More details can be found at:
  
          http://www.tornadoweb.org/en/stable/httpserver.html#http-server
  
          If None, no extra arguments are passed (default: None)
  
  Additionally, the following options may be passed to configure the
  operation of ``Server``:
  
  .. bokeh-options:: _ServerOpts
      :module: bokeh.server.server
  
  Any remaining keyword arguments will be passed as-is to
  ``BokehTornado``.
docstr_tok: ["Create","a","``","Server","``","instance",".","Args",":","applications","(","dict","[","str",",","Application","]","or","Application","or","callable",")",":","A","mapping","from","URL","paths","to","Application","instances",",","or","a","single","Application","to","put","at","the","root","URL",".","The","Application","is","a","factory","for","Documents",",","with","a","new","Document","initialized","for","each","Session",".","Each","application","is","identified","by","a","path","that","corresponds","to","a","URL",",","like","``","\/","''","or","``","\/myapp","''","If","a","single","Application","is","provided",",","it","is","mapped","to","the","URL","path","``","\/","''","automatically",".","As","a","convenience",",","a","callable","may","also","be","provided",",","in","which","an","Application","will","be","created","for","it","using","``","FunctionHandler","``",".","io_loop","(","IOLoop",",","optional",")",":","An","explicit","Tornado","``","IOLoop","``","to","run","Bokeh","Server","code","on",".","If","None",",","``","IOLoop.current","(",")","``","will","be","used","(","default",":","None",")","http_server_kwargs","(","dict",",","optional",")",":","Extra","arguments","passed","to","``","tornado.httpserver.HTTPServer","``",".","E.g",".","``","max_buffer_size","``","to","specify","the","maximum","upload","size",".","More","details","can","be","found","at",":","http",":","\/\/www.tornadoweb.org\/en\/stable\/httpserver.html","#","http-server","If","None",",","no","extra","arguments","are","passed","(","default",":","None",")","Additionally",",","the","following","options","may","be","passed","to","configure","the","operation","of","``","Server","``",":","..","bokeh-options",":",":","_ServerOpts",":","module",":","bokeh.server.server","Any","remaining","keyword","arguments","will","be","passed","as-is","to","``","BokehTornado","``","."]
code: def __init__(
      self,
      applications: Mapping[str, Application | ModifyDoc]
      | Application
      | ModifyDoc,
      io_loop: IOLoop | None = None,
      http_server_kwargs: dict[str, Any] | None = None,
      **kwargs: Any,
  ) -> None:
      """Create a ``Server`` instance.
  
      Args:
          applications (dict[str, Application] or Application or callable) :
              A mapping from URL paths to Application instances, or a single
              Application to put at the root URL.
  
              The Application is a factory for Documents, with a new Document
              initialized for each Session. Each application is identified
              by a path that corresponds to a URL, like "/" or "/myapp"
  
              If a single Application is provided, it is mapped to the URL
              path "/" automatically.
  
              As a convenience, a callable may also be provided, in which
              an Application will be created for it using
              ``FunctionHandler``.
  
          io_loop (IOLoop, optional) :
              An explicit Tornado ``IOLoop`` to run Bokeh Server code on. If
              None, ``IOLoop.current()`` will be used (default: None)
  
          http_server_kwargs (dict, optional) :
              Extra arguments passed to ``tornado.httpserver.HTTPServer``.
  
              E.g. ``max_buffer_size`` to specify the maximum upload size.
              More details can be found at:
  
              http://www.tornadoweb.org/en/stable/httpserver.html#http-server
  
              If None, no extra arguments are passed (default: None)
  
      Additionally, the following options may be passed to configure the
      operation of ``Server``:
  
      .. bokeh-options:: _ServerOpts
          :module: bokeh.server.server
  
      Any remaining keyword arguments will be passed as-is to
      ``BokehTornado``.
  
      """
      log.info(
          f"Starting Bokeh server version {__version__} (running on Tornado {tornado_version})"
      )
  
      opts = _ServerOpts(kwargs)
  
      if opts.num_procs > 1 and io_loop is not None:
          raise RuntimeError(
              "Setting both num_procs and io_loop in Server is incompatible. Use BaseServer to coordinate an explicit IOLoop and multi-process HTTPServer",
          )
  
      if opts.num_procs > 1 and sys.platform == "win32":
          raise RuntimeError("num_procs > 1 not supported on Windows")
  
      if opts.unix_socket and sys.platform == "win32":
          raise RuntimeError(
              "Unix sockets are not supported on windows."
          )
  
      if http_server_kwargs is None:
          http_server_kwargs = {}
      http_server_kwargs.setdefault("xheaders", opts.use_xheaders)
  
      if opts.ssl_certfile:
          log.info("Configuring for SSL termination")
          import ssl
  
          context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
          context.load_cert_chain(
              certfile=opts.ssl_certfile,
              keyfile=opts.ssl_keyfile,
              password=opts.ssl_password,
          )
          http_server_kwargs["ssl_options"] = context
  
      if opts.unix_socket:
          sockets = [netutil.bind_unix_socket(opts.unix_socket)]
          self._unix_socket = opts.unix_socket
          self._address, self._port = None, None
          if opts.allow_websocket_origin:
              extra_websocket_origins = create_hosts_allowlist(
                  opts.allow_websocket_origin, None
              )
          else:
              extra_websocket_origins = []
      else:
          sockets, self._port = bind_sockets(opts.address, opts.port)
          self._address = opts.address
  
          extra_websocket_origins = create_hosts_allowlist(
              opts.allow_websocket_origin, self.port
          )
  
      self._absolute_url = server_url(
          self._address, self._port, opts.ssl_certfile is not None
      )
  
      try:
          tornado_app = BokehTornado(
              applications,
              extra_websocket_origins=extra_websocket_origins,
              absolute_url=self._absolute_url,
              prefix=opts.prefix,
              index=opts.index,
              websocket_max_message_size_bytes=opts.websocket_max_message_size,
              **kwargs,
          )
  
          if opts.num_procs != 1:
              assert all(
                  app_context.application.safe_to_fork
                  for app_context in tornado_app.applications.values()
              ), (
                  "User application code has run before attempting to start "
                  "multiple processes. This is considered an unsafe operation."
              )
  
          http_server = HTTPServer(tornado_app, **http_server_kwargs)
  
          http_server.start(opts.num_procs)
          http_server.add_sockets(sockets)
  
      except Exception:
          for s in sockets:
              s.close()
          raise
  
      # Can only refer to IOLoop after HTTPServer.start() is called, see #5524
      if io_loop is None:
          io_loop = IOLoop.current()
  
      super().__init__(io_loop, tornado_app, http_server)
  
imports: from __future__ import annotations
  import logging
  import atexit
  import signal
  import socket
  import sys
  from types import FrameType
  from typing import TYPE_CHECKING, Any, Mapping
  from tornado import netutil, version
  from tornado.httpserver import HTTPServer
  from tornado.ioloop import IOLoop
  from ..None import __version__
  from ..core import properties
  from ..core.properties import Bool, Int, Nullable, String
  from ..resources import DEFAULT_SERVER_PORT, server_url
  from ..util.options import Options
  from .tornado import DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES, BokehTornado
  from .util import bind_sockets, create_hosts_allowlist
label_desc: Use image node_id 1 to create a new Server object from inherited base classes: BaseServer with example: obj = Server(applications, io_loop, http_server_kwargs)