code: def data_url(content, mimetype=None):
      
      if isinstance(content, pathlib.Path):
          if not mimetype:
              mimetype = guess_type(content.name)[0]
          with content.open('rb') as fp:
              content = fp.read()
      else:
          if isinstance(content, text_type):
              content = content.encode('utf8')
      return "data:{0};base64,{1}".format(
          mimetype or 'application/octet-stream', b64encode(content).decode())
docs: Returns content encoded as base64 Data URI.
  
      :param content: bytes or str or Path
      :param mimetype: mimetype for
      :return: str object (consisting only of ASCII, though)
  
      .. seealso:: https://en.wikipedia.org/wiki/Data_URI_scheme