由于缺少必需的位置参数:'application',DispatcherMiddleware 不适用于 gunicorn,但如何指定?

DispatcherMiddleware doesn't work with gunicorn because of a missing required positional argument: 'application', but how to specify?

为了将不同的目标请求传递给他们特定的 DashApps,我已经将 DispatcherMiddleware 集成到我的 Flask 项目中。 在本地 运行 没问题,但是 Heroku 的 gunicorn 服务器缺少一个必需的位置参数:'application' 正如我调用我的应用程序一样。 我需要如何做位置参数才能得到它运行?

2020-11-04T08:14:23.211801+00:00 heroku[web.1]: State changed from starting to up
2020-11-04T08:15:55.608341+00:00 app[web.1]: [2020-11-04 08:15:55 +0000] [10] [ERROR] Error handling request /
2020-11-04T08:15:55.608354+00:00 app[web.1]: Traceback (most recent call last):
2020-11-04T08:15:55.608355+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle
2020-11-04T08:15:55.608355+00:00 app[web.1]:     self.handle_request(listener, req, client, addr)
2020-11-04T08:15:55.608356+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
2020-11-04T08:15:55.608356+00:00 app[web.1]:     respiter = self.wsgi(environ, resp.start_response)
2020-11-04T08:15:55.608424+00:00 app[web.1]: TypeError: run_simple() missing 1 required positional argument: 'application'
2020-11-04T08:15:55.611228+00:00 app[web.1]: 10.63.193.41 - - [04/Nov/2020:08:15:55 +0000] "GET / HTTP/1.1" 500 0 "-" "-"
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.serving import run_simple


from app_datacenter.flask_app import flask_app


from app_datacenter.dash_apps.sessionlist_dummydata import app as sessionlist
from app_datacenter.dash_apps.sessionreport_realdata import app as sessionreport




application = DispatcherMiddleware(flask_app,
    {
    '/app1': sessionlist.server,
    '/app2': sessionreport.server
    }
)




if __name__ == '__main__':
    run_simple(
        hostname='localhost',
        port=5000,
        application=application,
        use_reloader=True,
        use_debugger=True,
        use_evalex=True
    )
web: gunicorn run:run_simple --log-file=-

我发现我的错误 - 必须在 Procfile 中调用应用程序(而不是我之前尝试过的方法)。 使用此 Procfile 运行 没问题:

web: gunicorn run:application --log-file=-