Added argument for websocket_origin on BokehRenderer.app
@@ -127,15 +127,18 @@ class BokehRenderer(Renderer):
@bothmethod
- def app(self_or_cls, plot, show=False, new_window=False):
+ def app(self_or_cls, plot, show=False, new_window=False, websocket_origin=None):
"""
Creates a bokeh app from a HoloViews object or plot. By
- default simply attaches the plot to bokeh's curdoc and
- returns the Document, if show option is supplied creates
- an Application instance and displays it either in a browser
- window or inline if notebook extension has been loaded.
- Using the new_window option the app may be displayed in a
- new browser tab once the notebook extension has been loaded.
+ default simply attaches the plot to bokeh's curdoc and returns
+ the Document, if show option is supplied creates an
+ Application instance and displays it either in a browser
+ window or inline if notebook extension has been loaded. Using
+ the new_window option the app may be displayed in a new
+ browser tab once the notebook extension has been loaded. A
+ websocket origin is required when launching from an existing
+ tornado server (such as the notebook) and it is not on the
+ default port ('localhost:8888').
"""
renderer = self_or_cls.instance(mode='server')
# If show=False and not in noteboook context return document
@@ -154,13 +157,15 @@ class BokehRenderer(Renderer):
elif self_or_cls.notebook_context and not new_window:
# If in notebook, show=True and no new window requested
# display app inline
- return bkshow(app)
+ opts = dict(notebook_url=websocket_origin) if websocket_origin else {}
+ return bkshow(app, **opts)
# If app shown outside notebook or new_window requested
# start server and open in new browser tab
from tornado.ioloop import IOLoop
loop = IOLoop.current()
- server = Server({'/': app}, port=0, loop=loop)
+ opts = dict(allow_websocket_origin=[websocket_origin]) if websocket_origin else {}
+ server = Server({'/': app}, port=0, loop=loop, **opts)
def show_callback():
server.show('/')
server.io_loop.add_callback(show_callback)
