code: def result(mimetype="application/json", headers=None):
      def decorator(func):
          @functools.wraps(func)
          def wrapper(self, *args, **kwargs):
              data = None
              status = 0
              msg = ""
              try:
                  data = func(self, *args, **kwargs)
              except Exception as e:
                  msg = "{}".format(e)
                  status = -1
              if mimetype == "application/json":
                  data = json.dumps(gen_result(data, status, msg))
              if callable(headers):
                  headers_output = headers(self)
              else:
                  headers_output = headers
                  if headers is not None:
                      if "content-encoding" in headers:
                          buf = BytesIO()
                          with gzip.GzipFile(
                              mode="wb", fileobj=buf
                          ) as fp:
                              gzip_value = data.encode()
                              fp.write(gzip_value)
                          data = buf.getvalue()
              return data, mimetype, headers_output
  
          return wrapper
  
      return decorator
  
imports: import functools
  import gzip
  import json
  import os
  from io import BytesIO
  from flask import request
  from visualdl import LogReader
  from visualdl.python.cache import MemCache
  from visualdl.reader.graph_reader import GraphReader
  from visualdl.server import lib
  from visualdl.server.client_manager import ClientManager
  from visualdl.server.log import logger
label_desc: Use image node_id 2 for calling a global function with example usage: result(mimetype, headers) and returns: decorator, wrapper, data,  mimetype,  headers_output