To pass different target requests to their specific DashApps I've integrated a DispatcherMiddleware into my Flask project. Locally it's running fine, but gunicorn server at Heroku is missing one required positional argument: 'application' as I called my app. How do I need to do the positional argument to get it running?
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=-
I found my error - the application must be called inside the Procfile (and not the method as I tried before). With this Procfile it's running fine:
web: gunicorn run:application --log-file=-