Flask app wrapped with DispatcherMiddleware no longer has test_client
To add WSGI middleware to a Flask app, wrap and replace the app's wsgi_app
attribute. You're replacing the reference to the Flask app with a reference to some other WSGI app, which obviously won't have the same properties. By replacing wsgi_app
, you retain the reference to the Flask app but change the WSGI callable that backs it.
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
'/backend': backend_app.wsgi_app,
})