Hi,
I’m trying to embed a running app from bokeh server into a html page without the use of Flask. I’m able to get the script into the part of the Jinja2 template, but connection is refused when I open the created html file. The error I get is:
2018-03-02 16:42:32,788 Refusing websocket connection from Origin ‘file://’; use --allow-websocket-origin= to permit this; currently we allow origins set([‘localhost:5003’])
2018-03-02 16:42:32,789 403 GET /sliders/ws?bokeh-protocol-version=1.0&bokeh-session-id=Zjq1aabS166yeI0nYIyNDCFBq321SiqJr8OnT0rN5X1Z (::1) 1.27ms
``
Part of Chromium console output
[bokeh] Will inject Bokeh script tag with params {“elementid”:“6c319794-5d7d-4b98-b105-d290f63fb309”,“sessionid”:“Zjq1aabS166yeI0nYIyNDCFBq321SiqJr8OnT0rN5X1Z”,“use_for_title”:false}
autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:113 Bokeh: injecting CSS: http://localhost:5003/static/css/bokeh.min.css?v=40d5c9a6441908ce9b812db9e82be4d5
autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:115 Bokeh: injecting CSS: http://localhost:5003/static/css/bokeh-widgets.min.css?v=509e292d9a7ef7e9eb8382fcde7b4a6e
autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:117 Bokeh: injecting CSS: http://localhost:5003/static/css/bokeh-tables.min.css?v=aa783ffa4e290813a295a99cce2f8b5d
autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:27 Bokeh: all callbacks have finished
``
My script for running and making the html document is as follows:
import io
from jinja2 import Template
from bokeh.plotting import figure
from bokeh.resources import INLINE
from bokeh.embed import file_html, server_document, server_session
from bokeh.client import pull_session
TEMPLATE = Template(’’’
</head>
<body>
<h1>Header</h1>
<p>Test embed slider.py</p>
{{ script|safe }}
</body>
'''
)
url = ‘http://localhost:5003/sliders’
#session = pull_session(url=url)
#script = server_session(None, session.id, url=url)
script = server_document(url)
html = TEMPLATE.render(script = script)
with io.open(“sliders_embed.html”, mode=‘w+’, encoding=‘utf-8’) as f:
f.write(html)
``
Hence when I view sliders_embed.html in the browser I get the error stated in the beginning. I have tried using server_document or a combination of pull_session and server_session, but it gives the same error.
Any help would be appreciated. Thanks.