ipywidgets_server
ipywidgets_server copied to clipboard
deploy to Heroku?
I'm experimenting with the Dash framework (from plotly guys) and they made it very easy to deploy the app on Heroku. But I really prefer ipywidgets + bqplot.
So, I was wondering whether it is also already possible to use ipywidgets_server on Heroku. And, in the case of a positive answer, if you could point to some model I could follow.
Just a little background: I'm a economics/statistics professor in Brazil, mostly dealing with students familiar with R's Shiny. So, although ipywidgets is awesome to work in the classroom, the ability to share the applications built by the students with non-coding people as easily as with Shiny is a sad limitation in our ecosystem.
Appmode is a step in that direction, with the benefit of free hosting on github/mybinder, but with the limitations of mybinder bandwidth. Dash is another another step, with the limitation of not using using ipywidgets/bqplot and the benefit of easily deploying on the free tier of Heroku (the proof of the easiness is that they made me deploy my very first apps).
Sorry if my question is silly or misplaced, but I have the impression that your work is in a position to fill a huge gap. Thank you very much.
That's a great question!
I have limited experience with Heroku, and I certainly haven't tried with ipywidgets-server. I agree that some documentation on deployment to Heroku would be great -- it'd make a great hosting platform for ipywidgets-server.
I attempted to deploy example.py to heroku and ran into a few issues.
In my app folder, ipywidget_server, I create the following Procfile:
web: python -m ipywidgets_server.app --port $PORT example:vbox
...and the following requirements.txt:
ipywidgets_server
...and copy the example.py to this location.
Then at the command line I run:
heroku create ipywidget # my app name git add * git commit -m "initial commit" git push heroku master heroku ps:scale web=1 heroku open # to open web browser
Then I get the following log ( via heroku logs --tail):
2018-07-20T09:33:20.769780+00:00 heroku[web.1]: Starting process with command
python -m ipywidgets_server.app --port 20441 example:vbox2018-07-20T09:33:24.341155+00:00 app[web.1]: [WidgetsServer] Storing connection files in /tmp/ipywidgets_server_7lkprjxs. 2018-07-20T09:33:24.341256+00:00 app[web.1]: [WidgetsServer] Serving static files from /app/.heroku/python/lib/python3.6/site-packages/ipywidgets_server/static. 2018-07-20T09:33:24.347784+00:00 app[web.1]: [WidgetsServer] Ipywidgets server listening on port 20441. 2018-07-20T09:33:25.256904+00:00 heroku[web.1]: State changed from starting to up 2018-07-20T09:33:15.498635+00:00 app[api]: Deploy 2118cb6f by user [email protected] 2018-07-20T09:33:27.000000+00:00 app[api]: Build succeeded 2018-07-20T09:33:52.537352+00:00 heroku[router]: at=info method=GET path="/" host=ipywidget.herokuapp.com request_id=19c794e7-3e35-4cbe-9349-2c7152b15173 fwd="80.242.46.2" dyno=web.1 connect=0ms service=3ms status=200 bytes=1462 protocol=http 2018-07-20T09:33:52.710859+00:00 heroku[router]: at=info method=GET path="/main.js" host=ipywidget.herokuapp.com request_id=8c199b9e-3dd4-4755-a000-4ca4ae6756c5 fwd="80.242.46.2" dyno=web.1 connect=0ms service=2ms status=304 bytes=176 protocol=http 2018-07-20T09:33:52.955581+00:00 heroku[router]: at=info method=GET path="/dist/libwidgets.js" host=ipywidget.herokuapp.com request_id=608e8381-0b2b-4387-9916-ab7d86e8d390 fwd="80.242.46.2" dyno=web.1 connect=0ms service=125ms status=200 bytes=6922989 protocol=http 2018-07-20T09:33:56.337878+00:00 heroku[router]: at=info method=GET path="/api/kernelspecs?1532079235203" host=ipywidget.herokuapp.com request_id=9987a71b-137d-4277-a1cd-60e7f3fcd14e fwd="80.242.46.2" dyno=web.1 connect=0ms service=3ms status=403 bytes=307 protocol=http 2018-07-20T09:33:56.336402+00:00 app[web.1]: [WidgetsServer] WARNING | Blocking request with non-local 'Host' ipywidget.herokuapp.com (ipywidget.herokuapp.com). If the notebook should be accessible at that name, set NotebookApp.allow_remote_access to disable the check. 2018-07-20T09:33:56.336608+00:00 app[web.1]: [WidgetsServer] WARNING | Forbidden 2018-07-20T09:33:56.337085+00:00 app[web.1]: WARNING:tornado.access:403 GET /api/kernelspecs?1532079235203 (10.99.224.73) 1.42ms
So I tried adding the following to example.py, but it did not help:
c = get_config() c.NotebookApp.allow_remote_access = True c.NotebookApp.allow_origin = 'ipywidget.herokuapp.com'`
The error message "Blocking request with non-local 'Host'" seems to come from the notebook.base.handlers.IPythonHandler class, but I can't see where that is imported into the ipywidget_server package.
Any ideas on how to solve the request blocking?
Thank you!
See also https://github.com/pbugnion/ipywidgets_server/issues/37