如何使Bokeh与REST api后端(而不是bokeh-serve)一起使用? [英] How to make Bokeh work with a REST api backend instead of bokeh-serve?
问题描述
如何使用CustomJS而不是bokeh-serve使Bokeh与我自己的REST api后端一起工作? components()
似乎不呈现输入,并且输入似乎总是需要运行bokeh-serve.
How can I make Bokeh work with my own REST api backend using CustomJS instead of bokeh-serve? components()
do not seem to render inputs and inputs seem to come always with a need to run bokeh-serve.
推荐答案
Barnabas,如果您不提供实际代码并详细描述 ,那么基本上不可能诊断出问题尝试过的. FWIW这是一个最小的脚本,可在Flask应用程序中呈现Bokeh Button
:
Barnabas, it is basically impossible to diagnose a problem if you do not provide actual code and describe in extreme detail what you have already tried. FWIW here is a minimal script that renders a Bokeh Button
in a Flask app:
导入烧瓶
from bokeh.embed import components
from bokeh.core.templates import FILE
from bokeh.models.widgets import Button
from bokeh.resources import INLINE
from bokeh.util.string import encode_utf8
app = flask.Flask(__name__)
@app.route("/")
def foo():
button = Button(label="test")
script, div = components(button, INLINE)
html = FILE.render(
plot_script=script,
plot_div=div,
bokeh_js=INLINE.render_js(),
bokeh_css=INLINE.render_css(),
)
return encode_utf8(html)
app.run(debug=True)
在真正的部署中,我确实会做些不同的事情(例如,没有INLINE
资源),但是如果没有有关您的实际用例或您真正想做的事情的附加信息,就不可能提供其他指导.
There are things I'd certainly do different in a real deployment (no INLINE
resources, e.g) but without additional information about your actual use-case or what you are really wanting to do it is impossible to offer additional guidance.
这篇关于如何使Bokeh与REST api后端(而不是bokeh-serve)一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!