How to embed an app/document with a custom template?

Hi all,

This is possibly a trivial question, but I’m new to Bokeh and I have essentially no experience with html or javascript.

I run bokeh directory application ( and it works perfectly well with new template feature(dash_template.png).

bokeh serve --show --allow-websocket-origin=localhost:8080 --allow-websocket-origin=localhost:5006 dash

After that I want to embed this application into flask using server_session ( (server_session_embed.png):

from flask import Flask, render_template

from bokeh.client import pull_session

from bokeh.embed import server_session

app = Flask(name)

@app.route(’/’, methods=[‘GET’])

def bkapp_page():

pull a new session from a running Bokeh server

with pull_session(url=“http://localhost:5006/dash”) as session:

generate a script to load the customized session

script = server_session(, url=‘http://localhost:5006/dash’)

use the script in the rendered page

return render_template(“embed.html”, script=script, template=“Flask”)

if name == ‘main’:


<!doctype html>

{{ script|safe }}

Change session.template in pull_session don’t help too.

Is it possible to render script from server_session with new template feature (