-
-
Notifications
You must be signed in to change notification settings - Fork 16k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flask run is not compatible with werkzeug middlewares #3256
Comments
I implemented the patch according to the suggestion, and it seems to work with the existing tests, however, I didn't add any new – there is a |
The WSGI callable for a Flask application is app = Flask("api")
admin = Flask("admin")
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {"/admin": admin}) See the docs. |
I could do that too but it feels... a hack? It obviously doesn't do any harm, but still. Also, the current behavior makes the application dispatching example from docs technically broken. |
@killthekitten the solution I pointed you at is the recommended way to do this. The The solution that you are proposing breaks the CLI, by the way. If your |
the example is correct flask.run uses Flask applications, the examples explicitly use wsgi server dispatching the documented method to apply a wsgi middleware to the wsgi details of an application is to replace the attribute as documented (its a necessary evil as wsgi middleware itself is a "decorator/proxy style pattern") |
👍 thanks for the details guys. I guess I'll have to live with it. |
Expected Behavior
When using
DispatcherMiddleware
to combine multiple flask apps, I expect to be able to run the app with the following command:Actual Behavior
The
app
object fails the following typecheck:flask/src/flask/cli.py
Line 198 in d4b688b
Environment
Suggestion
Drop the check when FLASK_APP is specified and it is not a factory, or change the check to allow for middlewares (it's hard to imagine such a check though).
Checking for type
Flask
makes sense withinfind_best_app
and at the moment ofcall_factory
result evaluation withinfind_app_by_string
.The text was updated successfully, but these errors were encountered: