Dash does not work properly with DispatcherMiddleware
See original GitHub issueConsider the following:
import flask
import dash
import dash_html_components as html
from werkzeug.wsgi import DispatcherMiddleware
app = flask.Flask(__name__)
flask_app = flask.Flask(__name__)
@flask_app.route('/')
def index():
return 'Flask App'
dash_app = dash.Dash(__name__)
dash_app.layout=html.Div('Dash App')
app.wsgi_app = DispatcherMiddleware(
flask_app,
{'/dash': dash_app.server},
)
if __name__ == '__main__':
app.run(debug=True, port=8050, host='0.0.0.0')
I would expect to see “Flask App” on localhost:8050/
and “Dash App” on localhost:8050/dash/
.
Instead, the Dash app doesn’t serve the _dash-*
files from the right place:
127.0.0.1 - - [08/Aug/2018 10:43:52] "GET /dash/ HTTP/1.1" 200 -
127.0.0.1 - - [08/Aug/2018 10:43:52] "GET /_dash-layout HTTP/1.1" 404 -
127.0.0.1 - - [08/Aug/2018 10:43:52] "GET /_dash-dependencies HTTP/1.1" 404 -
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Flask's DispatcherMiddleware not playing nice with Plotly's ...
This is how I overcame this problem. Not pretty but effective. You need run.py: from werkzeug.wsgi import DispatcherMiddleware from ...
Read more >Flask's DispatcherMiddleware not playing nice with Plotly's ...
Hi! This question is a copy of this SO question – consider posting the answer there and noting here if you've done so)....
Read more >Two Flask apps, frontend and admin, on one domain using ...
Using Werkzeug's dispatcher middleware we combine two Flask apps into a larger one with ... The DispatcherMiddleware object does not have a method...
Read more >How to Run Multiple Flask Applications from the Same Server
So if you have separate Flask, Django, or Dash applications you can run them in the same interpreter side by side if you...
Read more >Python – Running a Dash app within a Flask app
How can I run my Dash app within my existing Flask app? @app.route('/plotly_dashboard') def ... AttributeError: 'Dash' object has no attribute 'route' ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Did you try configuring the dash_app’s ‘config.requests_pathname_prefix’ to use the prefix “dash”. I recall having to configure it so (was reverse proxying dash from nginx).
EDIT: Just tested your code, in this case set requests_pathname_prefix to a blank string. So: dash_app.config.requests_pathname_prefix = “”
Was able to get it to route properly.
I realize this is closed but I’ve been banging my head against a wall trying to figure this out
DO NOT HAVE A TRAILING SLASH in your DispatchMiddleware mount points e.g.
Failing to do so will result in 308 redirects