I’m trying to embed a document with a custom extension into a Flask application. The Flask application is taken from the documentation found at https://bokeh.pydata.org/en/latest/docs/user_guide/server.html#connecting-with-bokeh-client
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():
with pull_session(url="http://localhost:5006/main") as session:
script = server_session(session_id=session.id, url='http://localhost:5006/main')
return render_template("embed.html", script=script, framework="Flask")
if name == ‘main’:
app.run(port=8080)
``
The extension is defined is equivalent to the custom extension found in the documentation at https://bokeh.pydata.org/en/latest/docs/user_guide/extensions.html#userguide-extensions. The document is constructed with the following script
from bokeh.io import show, output_file
from bokeh.layouts import column
from bokeh.models import Slider
from bokeh.plotting import figure, curdoc
from custom import Custom
slider = Slider(start=0, end=10, step=0.1, value=0, title=“value”)
custom = Custom(text=“Special Slider Display”, slider=slider)
layout = column(slider, custom)
curdoc().add_root(layout)
``
The document is launched with bokeh serve --allow-websocket-origin=localhost:8080 --show main.py
For a document constructed using standard bokeh components this works without issues. If the document is constructed using the custom extension from the documentation and the document is constructed as seen above I get the following error message in the terminal from the Flask server: KeyError: “View model name ‘Custom’ not found”
It seems to me that the custom extension is not available to the bokeh client in the Flask server. From searching it seems that the issue has been discussed previously https://github.com/bokeh/bokeh/issues/3930 but the api seems to have changed since.
Is it possible to embed a document making use of a custom extension?
I’m relatively new to bokeh and i apologize if have not used the correct terminology in the context of bokeh document, application & server.
Thanks,
Rasmus