Let me start with some background, in case my initial premises are totally wrong:
I have a Flask app which generates a large amount of data for the user. I’d like to serve up an interactive bokeh plot for that data (like a dashboard). The interactions alter the data based on user-generated functions. From what I’ve read, this talking between the plotting and a python function means serving this as an app (such as the stock_app example) is the best way to handle this.
Before jumping down the rabbit hole of the coding question, let me ask: I will need to serve different interactive dashboards for each user, on demand. I’m still learning about bokeh server, so is this type of thing possible without spinning up multiple servers? Or is another approach more appropriate?
If this isn’t a terrible idea to begin with, here is my question
How do I serve up this applet? I’ve attempted to follow the stock_app example, but serving it up in Flask appears to not work with the new edition of the bokeh server (v. 0.11dev, which is awesome). So I’ve been stumbling on my own to recreate a similar case with the slider_app.
In short, I’ve wrapped the latest version of the slider_app into a class, SliderApp, with a method SliderApp.get_app() which returns the HBox layout of the app.
def get_app(self):
inputs = VBoxForm(children=[self.text, self.offset, self.amplitude, self.phase, self.freq])
hbox = HBox(childrend=[inputs, self.plot])
return hbox
``
This then gets called in the following, short Flask app:
from flask import render_template, Flask
from SliderApp import SliderApp
from pandas import DataFrame
from bokeh.embed import autoload_server
from bokeh.client import push_session
from bokeh.io import curdoc
from bokeh.resources import Resources
app = Flask(name)
@app.route(’/’)
def index():
applet = SliderApp()
layout = applet.get_app()
doc = curdoc().add(layout)
push_session(curdoc())
tag = autoload_server(layout, loglevel='debug')
return render_template('slider_app.html', tag=tag)
if name == ‘main’:
print(“STARTED”)
app.run(debug=True)
``
The html template is very simple:
{{ tag | safe }}``
I then (attempt) to run by invoking:
bokeh serve
``
followed by
python flask_app.py
``
Navigating to 127.0.0.1:5000/ there is nothing represented, and an error is in the console similar to:
[Error] Bokeh: Failed to repull session Error: Module `VBoxForm’ does not exists. The problem may be two fold. Either a model was requested that’s available in an extra bundle, e.g. a widget, or a custom model was requested, but it wasn’t registered before first usage.
``
The particular module in the error changes when re-running (or re-accessing the route) to Slider, HBox, etc. so I’m not sure how to interpret it (likely not the root issue?). Otherwise, the HTML was in fact rendered with the tag inserted where expected.
Any advice, one way or the other, on this would be much appreciated!