Serving interactive bokeh figure on heroku Serving interactive bokeh figure on heroku flask flask

Serving interactive bokeh figure on heroku


I'm just going to answer my own question since I was eventually able to get this to work and nobody else has answered it yet.

I ended up with a Procfile that looked like this:

web: bokeh serve --port=$PORT --host=myapp.herokuapp.com --host=* \     --address=0.0.0.0 --use-xheaders myapp.py

a bit of background on what all of these arguments mean (as far as I can tell):

--port: specifies the port that the bokeh server will listen on, $PORT is set by heroku

--host=myapp.herokuapp.com and --host=*: specify the host name as myapp.heroku..., the wildcard is supposed to allow all hosts to be accepted. I'm not sure this in needed anymore.

--address=0.0.0.0: I think this tells bokeh to figure out on its own, which IP address it will be on.

--use-xheaders: causes bokeh to override the remote IP and URI scheme/protocol

I'm happy to make edits to this or accept a more knowledgeable users answer if there are issues with this approach.


The accepted answer didn't work for me as written (likely due to a bokeh version difference), but since this is still one of the top hits for this question, here is my minor modification that did work:

web: bokeh serve --port=$PORT --num-procs=0 --allow-websocket-origin=myapp.herokuapp.com --address=0.0.0.0 --use-xheaders myapp.py