☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Need help for Connecting with bokeh.client

Community Support
Julien1
Julien1

i try to connect to my bokeh.client how is running to show charts in flask app. But does’t work :

from flask import Flask, render_template
from bokeh.client import pull_session
from bokeh.embed import server_session

app = Flask(__name__)

@app.route('/')
def bkapp_page():

with pull_session(url="http://localhost:5006/bokeh_serv") as session:

    # generate a script to load the customized session
    script = server_session(session_id=session.id, url='http://localhost:5006/bokeh_serv')

    # use the script in the rendered page
    return render_template("embed.html", script=script, template="Flask")

if __name__ == '__main__':
    app.run(port=8080)

But when i go to http://localhost:8080/ there is nothing (i have charts with http://localhost:5006/bokeh_serv)

Someone have any idea ?

Julien

⌁   Link to post
nghenzi
nghenzi

You can check this answer a weeks ago

⌁   Link to post
_jm
_jm

@Julien1

A few points, some inferred based on how I think you are running things.

Indentation matters. The code that is cut-and-pasted into this topic looks off. I assume that everything within the pull_session() block of code should be indented as part of the bkapp_page() function that defines the default route for Flask.

If so, then your code for the flask app looks fine.

I assume that you are running the bokeh server as a separate process via something along the lines of

bokeh serve bokeh_serv.py

If so, the reason that you most likely see a blank page when navigating to the URL http://localhost:8080 is that the bokeh server is disallowing connections from the host:port combination of the Flask app that is trying to connect to it. You should see such a message in the terminal window where you run the bokeh server.

Try the following when invoking the bokeh server …

bokeh serve bokeh_serv.py --allow-websocket-origin=localhost:8080

⌁   Link to post
_jm
_jm

@Julien1

You can use the wildcard, i.e. --allow-websocket-orign='*' to accept connections from any origin, but this is generally only recommended for testing b/c of security reasons.

If you want to allow more than one origin, you can specify multiple allowed origins in the bokeh serve command.

From the bokeh server documentation in the Network Configuration section.

https://docs.bokeh.org/en/latest/docs/reference/command/subcommands/serve.html

It is possible to specify multiple allowed websocket origins by adding the --allow-websocket-origin option multiple times and to provide a comma separated list of hosts to BOKEH_ALLOW_WS_ORIGIN

⌁   Link to post

End of archived discussion · Replies are disabled