code: def serve(
      html,
      ip="127.0.0.1",
      port=8888,
      n_retries=50,
      files=None,
      jupyter_warning=True,
      open_browser=True,
      http_server=None,
  ):
      """Start a server serving the given HTML, and (optionally) open a browser
  
      Parameters
      ----------
      html : string
          HTML to serve
      ip : string (default = '127.0.0.1')
          ip address at which the HTML will be served.
      port : int (default = 8888)
          the port at which to serve the HTML
      n_retries : int (default = 50)
          the number of nearby ports to search if the specified port is in use.
      files : dictionary (optional)
          dictionary of extra content to serve
      jupyter_warning : bool (optional)
          if True (default), then print a warning if this is used within Jupyter
      open_browser : bool (optional)
          if True (default), then open a web browser to the given HTML
      http_server : class (optional)
          optionally specify an HTTPServer class to use for showing the
          figure. The default is Python's basic HTTPServer.
      """
      port = find_open_port(ip, port, n_retries)
      Handler = generate_handler(html, files)
  
      if http_server is None:
          srvr = server.HTTPServer((ip, port), Handler)
      else:
          srvr = http_server((ip, port), Handler)
  
      if jupyter_warning:
          try:
              __IPYTHON__  # noqa
          except NameError:
              pass
          else:
              print(JUPYTER_WARNING)
  
      # Start the server
      print(
          "Serving to http://{}:{}/    [Ctrl-C to exit]".format(
              ip, port
          )
      )
      sys.stdout.flush()
  
      if open_browser:
          # Use a thread to open a web browser pointing to the server
          def b():
              return webbrowser.open("http://{}:{}".format(ip, port))
  
          threading.Thread(target=b).start()
  
      try:
          srvr.serve_forever()
      except (KeyboardInterrupt, SystemExit):
          print("\nstopping Server...")
  
      srvr.server_close()
  
file_path: altair/altair/utils/server.py
imports: import sys
  import threading
  import webbrowser
  import socket
  from http import server
  from io import BytesIO
  import itertools
  import random
label_desc: Use image node_id 3 for calling a global function with example usage: serve(html, ip, port, n_retries, files, jupyter_warning, open_browser, http_server) and returns: webbrowser