Before everything, I would like to thank you for your patience and understanding and all the effort you guys put into bokeh project…
I’m following this tutorial. When I checked the source of that page, I see the script of embeded bokeh app is as follows:
<script src="/bokeh/deploy_bokeh_app/autoload.js?bokeh-autoload-element=1171&bokeh-app-path=/bokeh/deploy_bokeh_app" id="1171"></script>
It has a prefix before the filename of bokeh app. And as far as I know he is using bokeh 0.13.0.
But in my case (bokeh 1.4.0), I don’t have filename in the script tag, only the prefix is placed in the tag. Meaning, I have something like the following:
<script src="/bokeh/autoload.js?bokeh-autoload-element=1171&bokeh-app-path=/bokeh" id="1171"></script>
I have two different files: One for flask and another for bokeh applications. Flask app is embedding bokeh app as follows:
@application.route("/")
def index():
try:
tag = server_document(url=r'/bokeh', relative_urls=True)
return render_template('index.html', tag=tag)
except Exception as e:
return str(e)
And in bokeh app (the file is called run_bokeh.py) I have the following code:
from numpy.random import random
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.layouts import column, widgetbox
from bokeh.models import Button, ColumnDataSource
from bokeh.server.server import Server
def run(doc):
fig = figure(title='random data', width=400, height=400, tools='')
source = ColumnDataSource(data={'x': range(100), 'y': random(100)})
fig.line('x', 'y', source=source)
def click(n=100):
global per_callback_id
source.data = {'x': range(n), 'y': random(n)}
start_button = Button(label='start', button_type='success')
start_button.on_click(click)
layout = column(start_button, fig)
doc.add_root(layout)
# configure and run bokeh server
kws = {
'port': 5100,
'prefix': '/bokeh',
'allow_websocket_origin': ['37.148.208.160']
}
server = Server(run, **kws)
server.start()
if __name__ == '__main__':
server.io_loop.add_callback(server.show, '/')
server.io_loop.start()
Since the prefix is “bokeh” and the bokeh application’s filename is “run_bokeh.py” I would expect that the tag produced by server_document to be like:
<script src="/bokeh/run_bokeh/autoload.js?bokeh-autoload-element=1171&bokeh-app-path=/bokeh/run_bokeh" id="1171"></script>
Instead I got the tag like:
<script src="/bokeh/autoload.js?bokeh-autoload-element=1171&bokeh-app-path=/bokeh" id="1171"></script>