I now I can integrate Python Dash with Flask, but is it possible to have more than one dashboards within single Flask application? The reason is that I want to have different dashboards for different User Groups, and I want each dashboard to scale independently from the other.
1 Answer
You can just create multiple dash instances. I'm not exactly sure what you mean with scale independently?
Example
Below is a minimal example of creating 2 dash instances. You can just add your figures and callbacks as you're used to.
import dash
import dash_html_components as html
from flask import Flask
server = Flask(__name__)
# Set-up endpoint 1
app_1 = dash.Dash(__name__, server=server, url_base_pathname='/app1/')
app_1.layout = html.H1('App 1')
# Set-up endpoint 2
app_2 = dash.Dash(__name__, server=server, url_base_pathname='/app2/')
app_2.layout = html.H1('App 2')
# Run server
server.run()
3 Comments
strubbly
I can't get this to work with a recent version of Dash: I'm just getting 404 errors for all urls.
strubbly
Yes - but I've realised the problem is in my web-config - how the web server is configured. It wasn't running wfastcgi for /app1/. Obvious really - sorry.
nedned
Since Dash 2.0 this pattern is not longer supported. Each Dash instance now sets up global state in the dash module, so only one Dash instance should be run in a process at time, otherwise you'll find things breaking in weird and surprising ways.