code: def setup_app(app, cfg):
      
      # Set up app_host and app_port in case that we are running
      # under reverse proxy setup, otherwise they default to
      # config.host and config.port.
      if (cfg.app_host and cfg.app_port):
          logging.warning("Reverse proxy for service at http://%s:%d/ ..." % (cfg.host, cfg.port))
          app.wsgi_app = ReverseProxied(app.wsgi_app, cfg.host)
      elif (cfg.app_host or cfg.app_port):
          logging.critical("Must specify both app-host and app-port for reverse proxy configuration, aborting")
          sys.exit(1)
      else:
          cfg.app_host = cfg.host
          cfg.app_port = cfg.port
      logging.warning("Setup server on http://%s:%d/ ..." % (cfg.app_host, cfg.app_port))
      return(app)
docs: Setup Flask app and handle reverse proxy setup if configured.
  
      Arguments:
          app - Flask application
          cfg - configuration data