Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A patch proposal for multi-app setups #69

Closed
wants to merge 1 commit into from

Conversation

Volodymyrk
Copy link

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
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