code: def _to_html(spec, path, iframe: bool) -> Union[str, None]:
      if iframe is None:
          iframe = False
  
      from .. import _kbridge as kbr
  
      html_page = kbr._generate_static_html_page(spec.as_dict(), iframe)
  
      if isinstance(path, str):
          abspath = _makedirs(path)
          with io.open(abspath, mode="w", encoding="utf-8") as f:
              f.write(html_page)
              return abspath
      else:
          path.write(html_page.encode())
          return None
  
imports: import io
  import json
  import os
  from typing import Union
  from lets_plot._global_settings import get_global_bool, has_global_value, FRAGMENTS_ENABLED
label_desc: Use image node_id 8 for calling a global function with example usage: _to_html(spec, path, iframe) and returns: None, abspath