如何使Bokeh使用RESTAPI后端而不是Bokeh服务工作?

如何使Bokeh使用RESTAPI后端而不是Bokeh服务工作?,bokeh,Bokeh,如何使用CustomJS而不是bokehserve使Bokeh与我自己的restapi后端一起工作components()似乎不会呈现输入,并且输入似乎总是需要运行bokeh serve。Barnabas,如果您不提供实际代码并极其详细地描述您已经尝试过的内容,则基本上不可能诊断出问题。FWIW这里是一个在Flask应用程序中呈现Bokeh按钮的最小脚本: 进口烧瓶 from bokeh.embed import components from bokeh.core.templates impo

如何使用CustomJS而不是bokehserve使Bokeh与我自己的restapi后端一起工作
components()
似乎不会呈现输入,并且输入似乎总是需要运行bokeh serve。

Barnabas,如果您不提供实际代码并极其详细地描述您已经尝试过的内容,则基本上不可能诊断出问题。FWIW这里是一个在Flask应用程序中呈现Bokeh
按钮的最小脚本:

进口烧瓶

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)

在实际部署中,我当然会做一些不同的事情(例如,没有
内联
资源),但是如果没有关于您的实际用例或您真正想要做什么的额外信息,就不可能提供额外的指导

Barnabas,如果您不提供实际的代码并极其详细地描述您已经尝试过的内容,则基本上不可能诊断问题。FWIW这里是一个在Flask应用程序中呈现Bokeh
按钮的最小脚本:

进口烧瓶

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)

在实际部署中,我当然会做一些不同的事情(例如,没有
内联
资源),但是如果没有关于您的实际用例或您真正想要做什么的额外信息,就不可能提供额外的指导

事实证明,要使用小部件,需要在html页面中添加额外的js和css。
就我而言,这些是

  • bokeh-0.11.1.min.js
  • bokeh-widgets-0.11.1.min.js
  • bokeh-compiler-0.11.1.min.js和
  • bokeh-widgets-0.11.1.min.css

事实证明,要使用小部件,需要在html页面中添加额外的js和css。
就我而言,这些是

  • bokeh-0.11.1.min.js
  • bokeh-widgets-0.11.1.min.js
  • bokeh-compiler-0.11.1.min.js和
  • bokeh-widgets-0.11.1.min.css