在烧瓶中嵌入散景应用程序 [英] Embedding a bokeh app in flask

查看:33
本文介绍了在烧瓶中嵌入散景应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拼命地尝试将一个工作散景小程序嵌入烧瓶中,但找不到合适的方法来做到这一点.我查看了所有示例,但找不到包含更新数据功能的示例(最佳示例:slider_applet).

I am trying desperately to embed a working bokeh applet into flask, and can't find a proper way to do this. I looked through all the examples, but I can't find one which includes the ability to update the data (best example: the sliders_applet).

如果我没记错的话,我确实需要散景服务器才能更改数据(使用滑块等).以这种方式启动小程序是有效的,例如:

If I'm not mistaken, I do need the bokeh-server to be able to change the data (with sliders etc.). Starting the applet this way works, e.g.:

bokeh-server --script sliders_app.py

但我找不到合适的方法,或者至少找不到将滑块应用程序嵌入烧瓶的工作方法.而且由于应该可以使用多个小程序,因此在散景服务器启动时也指定一个小程序对我来说似乎并不干净..

But I can't find the proper, or at least a working way to embed the sliders_app into flask. And since it should be possible to use multiple applets, it doesn't seem clean to me to specify one single applet at the startup of the bokeh server too..

我很乐意提供任何帮助 - 散景对我来说是一个很棒的工具.

I would gladly appreciate any help - bokeh looks like a great tool for me.

推荐答案

另一个答案没有描述如何嵌入 Bokeh 服务器应用程序(它使用 components 嵌入独立的 Bokeh 文档).

The other answer does not describe how to embed a Bokeh server app (it uses components to embed a standalone Bokeh document).

首先,您可以在以下位置看到许多现场示例:https://demo.bokeh.org/

First, you can see lots of live examples hosted at: https://demo.bokeh.org/

对于嵌入应用程序,有两个常用选项:

For embedding apps there are two usual options:

后者通常是这样使用的:

The latter is usually used like this:

from bokeh.embed import server_document
script = server_document("https://demo.bokeh.org/sliders")

这将返回一个类似于下面的

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆