I am trying to create a larger scale dashboard hosting app. This will contain many dash apps, each with multiple pages. I am getting an error when trying to put pages in separate Dash apps with the same name:
Exception: modules ['dashboards.dash1.pages.home', 'dashboards.dash2.pages.home'] have duplicate paths
I need to be able to run these dash apps without having naming conflicts. I have checked the page registry which shows dash is mixing up the relative paths. I understand that just not naming the pages is a solution but we are going to have lots of dashboards and that is not a suitable solution.
module dashboards.dash1.pages.home
supplied_path /home
path_template None
path /home
supplied_name home
name home
supplied_title None
title home
description
order None
supplied_order None
supplied_layout None
supplied_image None
image None
image_url None
redirect_from None
relative_path /dash1/home <---- SAME VALUES
layout H1('Dash 1 Home')
module dashboards.dash2.pages.home
supplied_path /home
path_template None
path /home
supplied_name home
name home
supplied_title None
title home
description
order None
supplied_order None
supplied_layout None
supplied_image None
image None
image_url None
redirect_from None
relative_path /dash1/home <---- SAME VALUES
layout H1('Dash 2 Home')
My codebase looks like this
.
├── app.py
└── dashboards
├── dash1
│ ├── __init__.py
│ └── pages
│ └── home.py
└── dash2
├── __init__.py
└── pages
└── home.py
app.py
from dashboards.dash1 import app as dash1
from dashboards.dash2 import app as dash2
app = Flask(__name__)
routes = {
"/dash1": dash1.server,
"/dash2": dash2.server
}
app.wsgi_app = DispatcherMiddleware(NotFound(), routes)
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
dash1/_init_.py
app = Dash("dash1", use_pages=True, pages_folder="dashboards/dash1/pages")
app.layout = html.Div([
html.H1(children='Dash 1', style={'textAlign':'center'}),
page_container
])
dash1/pages/home.py
register_page(__name__, name="home", path="/home")
layout = html.H1("Dash 1 Home")
dash2/_init_.py
app = Dash("dash2", use_pages=True, pages_folder="dashboards/dash2/pages")
app.layout = html.Div([
html.H1(children='Dash 2', style={'textAlign':'center'}),
page_container
])
dash2/pages/home.py
register_page(__name__, name="home", path="/home")
layout = html.H1("Dash 2 Home")
I appreciate the time you took to read this long ass post!
Got confirmation that Dash does not support multiple instances running on the same process as there are many global states
https://github.com/plotly/dash/issues/2812