code: def initialize_flask(config, init_static_thread, no_studio):
      logger.debug("Initializing flask..")
      # region required for windows https://github.com/mindsdb/mindsdb/issues/2526
      mimetypes.add_type("text/css", ".css")
      mimetypes.add_type("text/javascript", ".js")
      # endregion
  
      kwargs = {}
      if no_studio is not True:
          static_path = os.path.join(
              config["paths"]["static"], "static/"
          )
          if os.path.isabs(static_path) is False:
              static_path = os.path.join(os.getcwd(), static_path)
          kwargs["static_url_path"] = "/static"
          kwargs["static_folder"] = static_path
          logger.debug(f"Static path: {static_path}")
  
      app = Flask(__name__, **kwargs)
  
      app.config["SECRET_KEY"] = os.environ.get(
          "FLASK_SECRET_KEY", secrets.token_hex(32)
      )
      app.config["SESSION_COOKIE_NAME"] = "session"
      app.config["PERMANENT_SESSION_LIFETIME"] = datetime.timedelta(
          days=31
      )
      app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 60
      app.config["SWAGGER_HOST"] = "http://localhost:8000/mindsdb"
      app.json_encoder = CustomJSONEncoder
  
      authorizations = {
          "apikey": {
              "type": "session",
              "in": "query",
              "name": "session",
          }
      }
  
      logger.debug("Creating swagger API..")
      api = Swagger_Api(
          app,
          authorizations=authorizations,
          security=["apikey"],
          url_prefix=":8000",
          prefix="/api",
          doc="/doc/",
      )
  
      api.representations["application/json"] = custom_output_json
  
      port = config["api"]["http"]["port"]
      host = config["api"]["http"]["host"]
  
      # NOTE rewrite it, that hotfix to see GUI link
      if not no_studio:
          if host in ("", "0.0.0.0"):
              url = f"http://127.0.0.1:{port}/"
          else:
              url = f"http://{host}:{port}/"
          logger.info(f" - GUI available at {url}")
  
          pid = os.getpid()
          x = threading.Thread(
              target=_open_webbrowser,
              args=(
                  url,
                  pid,
                  port,
                  init_static_thread,
                  config["paths"]["static"],
              ),
              daemon=True,
          )
          x.start()
  
      return app, api
  
imports: import datetime
  import mimetypes
  import os
  import secrets
  import threading
  import traceback
  import webbrowser
  from distutils.version import LooseVersion
  from pathlib import Path
  import requests
  from flask import Flask, url_for, make_response, request, send_from_directory
  from flask.json import dumps
  from flask_compress import Compress
  from flask_restx import Api
  from werkzeug.exceptions import HTTPException
  from mindsdb.__about__ import __version__
  from mindsdb.api.http.gui import update_static
  from mindsdb.api.http.utils import http_error
  from mindsdb.api.http.namespaces.agents import ns_conf
  from mindsdb.api.http.namespaces.analysis import ns_conf
  from mindsdb.api.http.namespaces.auth import ns_conf
  from mindsdb.api.http.namespaces.chatbots import ns_conf
  from mindsdb.api.http.namespaces.config import ns_conf
  from mindsdb.api.http.namespaces.databases import ns_conf
  from mindsdb.api.http.namespaces.default import ns_conf, check_auth
  from mindsdb.api.http.namespaces.file import ns_conf
  from mindsdb.api.http.namespaces.handlers import ns_conf
  from mindsdb.api.http.namespaces.models import ns_conf
  from mindsdb.api.http.namespaces.projects import ns_conf
  from mindsdb.api.http.namespaces.skills import ns_conf
  from mindsdb.api.http.namespaces.sql import ns_conf
  from mindsdb.api.http.namespaces.tab import ns_conf
  from mindsdb.api.http.namespaces.tree import ns_conf
  from mindsdb.api.http.namespaces.views import ns_conf
  from mindsdb.api.http.namespaces.util import ns_conf
  from mindsdb.interfaces.database.integrations import integration_controller
  from mindsdb.interfaces.database.database import DatabaseController
  from mindsdb.interfaces.file.file_controller import FileController
  from mindsdb.interfaces.storage import db
  from mindsdb.utilities import log
  from mindsdb.utilities.config import Config
  from mindsdb.utilities.context import context
  from mindsdb.utilities.json_encoder import CustomJSONEncoder
  from mindsdb.utilities.ps import is_pid_listen_port, wait_func_is_true
  from mindsdb.utilities.telemetry import inject_telemetry_to_static
label_desc: Use image node_id 6 for calling a global function with example usage: initialize_flask(config, init_static_thread, no_studio) and returns: app,  api