code: def generate_handler(html, files=None):
      if files is None:
          files = {}
  
      class MyHandler(server.BaseHTTPRequestHandler):
          def do_GET(self):
              """Respond to a GET request."""
              if self.path == "/":
                  self.send_response(200)
                  self.send_header("Content-type", "text/html")
                  self.end_headers()
                  self.wfile.write(
                      "<html><head>"
                      "<title>LDAvis</title>"
                      "</head><body>\n".encode()
                  )
                  self.wfile.write(html.encode())
                  self.wfile.write("</body></html>".encode())
              elif self.path in files:
                  content_type, content = files[self.path]
                  self.send_response(200)
                  self.send_header("Content-type", content_type)
                  self.end_headers()
                  self.wfile.write(content.encode())
              else:
                  self.send_error(404)
  
      return MyHandler
  
file_path: pyLDAvis/pyLDAvis/_server.py
imports: import sys
  import threading
  import webbrowser
  import socket
  import itertools
  import random
  from http import server
label_desc: Use image node_id 1 for calling a global function with example usage: generate_handler(html, files) and returns: MyHandler