Skip to content

A patch proposal for multi-app setups#69

Closed
Volodymyrk wants to merge 1 commit into
plotly:masterfrom
Volodymyrk:master
Closed

A patch proposal for multi-app setups#69
Volodymyrk wants to merge 1 commit into
plotly:masterfrom
Volodymyrk:master

Conversation

@Volodymyrk

Copy link
Copy Markdown

This patch address my question on SO
https://stackoverflow.com/questions/44744709/how-to-organise-a-plotly-dash-project

In order to serve multiple apps with one interpreter, I am using a DispatcherMiddleware from werkzeug.wsgi:
http://flask.pocoo.org/docs/0.12/patterns/appdispatch/

I'd like to avoid running multiple gunicorns on different ports, as this will complicate the setup unnecessary, IMO.

So my structure is as follows:

run.py

from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware

# importing apps
from index_app import app as app_ix
from app1 import app as app1
from app2 import app as app2
from app3 import app as app3

application = DispatcherMiddleware(app_ix, {
    '/app1': app1.server,
    '/app2': app2.server,
    '/app3': app3.server
})

# local debug
if __name__ == '__main__':
    run_simple('localhost', 5001, application)

and app1.py

import dash
import dash_core_components as dcc
import dash_html_components as html

from dash.dependencies import Input, Output
app = dash.Dash(app_path='/{}'.format(__name__))
...

Without my changes, however, individual apps don't know that they are served on a separate URL path and couldn't find resources, such as layout, etc.

Let me know if there is a better way to build a multi-page dash apps.

@Volodymyrk

Copy link
Copy Markdown
Author

I believe that rc1405 solution in #70 is better .
However, if we want to allow the use of DispatcherMiddleware(), #70 alone is not enough.
Overall, feel free to Close this one - I wanted to start the conversation, hence proposed a dirty hack.

@Volodymyrk Volodymyrk closed this Dec 8, 2017
HammadTheOne pushed a commit to HammadTheOne/dash that referenced this pull request May 28, 2021
HammadTheOne pushed a commit that referenced this pull request Jul 23, 2021
Fix external_url bundle name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant