Is this a bug or an intentional change in the new release?

Hi. I’m working on a flask+bokeh website project. Up till now, I managed to serve one bokeh app and embed it into a webpage controlled by flask. Now I’m trying to make this logic work with multiple bokeh apps. During trials, I figured that server_document method returns the script tag with only the prefix not the full url. Meaning that: I have a bokeh file called and inside that file I’m serving the bokeh plot with a prefix: “bokeh”. The generated tag is

<script src="/bokeh/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh" id="1000"></script>


<script src="/bokeh/foo/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh/foo" id="1000"></script>

Is this a bug or an intentional thing?

@Saba_Arife_Bozpolat I can’t say I know offhand, tho I guess I would also take the position that all the URL args to autoload.js are implementation details that users should not directly deal with. So really more details/context about what you are trying to do is needed to say more, especially if there is something that “used to work” that now “doesn’t work”, we would to know exactly what that something is (i.e. in terms of code) as well as the before/after Bokeh versions.

Edit: I guess to elaborate, for instance: I don’t really know what this means:

Meaning that: I have a bokeh file called and inside that file I’m serving the bokeh plot with a prefix: “bokeh”.

in terms of actual file, module layout, how you are calling server_document, etc. and all those details are important.

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:

def index():
    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 I have the following code:

from numpy.random import random
from 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 = {'x': range(n), 'y': random(n)}

    start_button = Button(label='start', button_type='success')

    layout = column(start_button, fig)

# configure and run bokeh server
kws = {
    'port': 5100,
    'prefix': '/bokeh',
    'allow_websocket_origin': ['']
server = Server(run, **kws)
if __name__ == '__main__':
    server.io_loop.add_callback(, '/')

Since the prefix is “bokeh” and the bokeh application’s filename is “” 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>

@Saba_Arife_Bozpolat Thank you very much for the kind words.

I took a look at the page also. It appear that he is using version 1.3.4 which is the last version before 1.4. Looking at the blame page the the relevant code, it has not changed in two years, which is well before 1.3.4. My recollection is also that this is always how server_document has functioned, namely that the user needs to provide the entire URL path of the Bokeh app on the remote Bokeh server. And this makes sense, because there is not really any way for server_document to know anything about how the remote Bokeh server is configured (i.e. if there is a prefix, what the app path is, etc). You need to supply that information to server_document.

My speculation is simply that this is a case of authorial license, i.e. that the author simplified what was presented in the article from the actual implementation used to embed the example app on that page, which is why they don’t match up. Long story short, you just need to provide the full path to the Bokeh app yourself:

tag = server_document(url=r'/bokeh/run_bokeh', relative_urls=True)