code: def initialize_app(config, no_studio):
      static_root = config["paths"]["static"]
      logger.debug(f"Static route: {static_root}")
      gui_exists = Path(static_root).joinpath("index.html").is_file()
      logger.debug(
          f"Does GUI already exist.. {'YES' if gui_exists else 'NO'}"
      )
      init_static_thread = None
      if no_studio is False and (
          config["gui"]["autoupdate"] is True or gui_exists is False
      ):
          init_static_thread = threading.Thread(
              target=initialize_static
          )
          init_static_thread.start()
  
      app, api = initialize_flask(config, init_static_thread, no_studio)
      Compress(app)
      initialize_interfaces(app)
  
      if os.path.isabs(static_root) is False:
          static_root = os.path.join(os.getcwd(), static_root)
      static_root = Path(static_root)
  
      @app.route("/", defaults={"path": ""}, methods=["GET"])
      @app.route("/<path:path>", methods=["GET"])
      def root_index(path):
          if path.startswith("api/"):
              return {"message": "wrong query"}, 400
          if static_root.joinpath(path).is_file():
              return send_from_directory(static_root, path)
          else:
              return send_from_directory(static_root, "index.html")
  
      protected_namespaces = [
          tab_ns,
          utils_ns,
          conf_ns,
          file_ns,
          sql_ns,
          analysis_ns,
          handlers_ns,
          tree_ns,
          projects_ns,
          databases_ns,
          views_ns,
          models_ns,
          chatbots_ns,
          skills_ns,
          agents_ns,
      ]
  
      for ns in protected_namespaces:
          api.add_namespace(ns)
      api.add_namespace(default_ns)
      api.add_namespace(auth_ns)
  
      @api.errorhandler(Exception)
      def handle_exception(e):
          logger.error(f"http exception: {e}")
          # pass through HTTP errors
          if isinstance(e, HTTPException):
              return (
                  {"message": str(e)},
                  e.code,
                  e.get_response().headers,
              )
          name = getattr(type(e), "__name__") or "Unknown error"
          return {"message": f"{name}: {str(e)}"}, 500
  
      @app.teardown_appcontext
      def remove_session(*args, **kwargs):
          db.session.remove()
  
      @app.before_request
      def before_request():
          logger.debug(f"HTTP: {request.path}")
          ctx.set_default()
          config = Config()
  
          # region routes where auth is required
          if (
              config["auth"]["http_auth_enabled"] is True
              and any(
                  request.path.startswith(f"/api{ns.path}")
                  for ns in protected_namespaces
              )
              and check_auth() is False
          ):
              return http_error(
                  403,
                  "Forbidden",
                  "Authorization is required to complete the request",
              )
          # endregion
  
          company_id = request.headers.get("company-id")
          user_class = request.headers.get("user-class")
  
          try:
              email_confirmed = int(
                  request.headers.get("email-confirmed", 1)
              )
          except ValueError:
              email_confirmed = 1
  
          if company_id is not None:
              try:
                  company_id = int(company_id)
              except Exception as e:
                  logger.error(
                      f"Cloud not parse company id: {company_id} | exception: {e}"
                  )
                  company_id = None
  
          if user_class is not None:
              try:
                  user_class = int(user_class)
              except Exception as e:
                  logger.error(
                      f"Cloud not parse user_class: {user_class} | exception: {e}"
                  )
                  user_class = 0
          else:
              user_class = 0
  
          ctx.company_id = company_id
          ctx.user_class = user_class
          ctx.email_confirmed = email_confirmed
  
      # Wait for static initialization.
      if not no_studio and init_static_thread is not None:
          init_static_thread.join()
  
      logger.debug("Done initializing app.")
      return app
  
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 5 for calling a global function with example usage: initialize_app(config, no_studio) and returns: app, dict,  int, dict,  int, send_from_directory, send_from_directory, dict,  e,  e, http_error