Here’s what I’m trying to do:
I want to be able to make multiple dashboards dynamically and server them on different URLs. I’ve made a quick sample code to illustrate:
from flask import Flask
import dash
import dash_html_components as html
application = Flask(__name__)
def make_dash(name):
app = dash.Dash(
name=f'{name}',
server=application,
sharing=True,
url_base_pathname=f'/{name}/'
)
app.layout = html.Div(f'Hello World {name}')
return app
app1 = make_dash('app1')
app2 = make_dash('app2')
if __name__ == '__main__':
application.run(debug=True, port=8050, host='0.0.0.0')
The output from this is:
AssertionError: A name collision occurred between blueprints <flask.blueprints.Blueprint object at 0x7fa7dfa688d0> and <flask.blueprints.Blueprint object at 0x7fa7df5ba898>. Both share the same name "assets". Blueprints that are created on the fly need unique names.
I get the same exception when trying to serve it with gunicorn
.
I’ve read through https://community.plotly.com/t/dash-on-multi-page-site-app-route-flask-to-dash/, but it seems like having a layout generated on the fly isn’t good enough, because my dynamically generated dashboards will have share element names.
I’ve also tried using werkzeug.wsgi.DispatcherMiddleware
', but when I do that, the various _dash-*
files still try to get served from the root of my server and they can’t be found.
Is there some way to make this work?