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

[Feature Request] Better documentation for using with Binder/JupyterHub #1057

Open
tdpetrou opened this issue Dec 30, 2019 · 2 comments
Open

Comments

@tdpetrou
Copy link

I write tutorials and do lots of live teaching and gravitate mostly to using Jupyter Notebooks, which allow for text and code to be integrated together in one. Using dash on a local instance of Jupyter is essentially no different than using it from a normal .py file.

But, when teaching to people that have no local jupyter instance or don't even have python installed, I've turned to Binder which relies on JupyterHub.

It took some searching, but I found some github issues and forum posts that informed me I had to set requests_pathname_prefix of the config dictionary like this.

port = 9999
base_prefix = '{}proxy/{}/'.format(os.environ['JUPYTERHUB_SERVICE_PREFIX'], port)
url = 'https://hub.gke.mybinder.org{}'.format(base_prefix)
app.config.update({'requests_pathname_prefix': base_prefix})
app = dash.Dash()
app.run_server(host='0.0.0.0', port=port)

Would be great if this was officially documented somewhere. Thanks and this is a great product. I'm doing a meetup on it in Houston on Jan 2 (apologies if this is self promotion, so no link provided).

@audetto
Copy link

audetto commented Mar 7, 2020

Fantastic. Been trying for hours to find the right combination of flags to make this work.

This is really worth documenting.

But, I wanted to ask about a "more elegant" solution, something I have seen working in r shiny.

The above solution will make the app work via the Reverse Proxy, but not natively (where the extra prefix breaks the links).

If Dash links were relative to the location of the first page, then the same app could work in both cases (or via multiple proxies).
I am sure there must be a good reason why the links in the html are absolute and not relative and I have no idea what is the tradeoff, but worth adding this to the doc as well.

@audetto
Copy link

audetto commented Mar 7, 2020

Now that I know, I can find examples and some sort of documentation

https://github.com/plotly/dash-recipes/blob/master/dash-routes-config.py
#179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants