[英]How to run a bokeh server without 'bokeh server --show' command?
I want to run a bokeh interactive application without using "bokeh serve --show" command.我想在不使用“bokeh serve --show”命令的情况下运行散景交互式应用程序。 Instead, I want to use 'python script_name.py' syntax.
相反,我想使用“python script_name.py”语法。 Is there any way to do this?
有没有办法做到这一点?
This is covered in the project documentation:这包含在项目文档中:
https://docs.bokeh.org/en/latest/docs/user_guide/server.html#embedding-bokeh-server-as-a-library https://docs.bokeh.org/en/latest/docs/user_guide/server.html#embedding-bokeh-server-as-a-library
from bokeh.server.server import Server
server = Server(
bokeh_applications, # list of Bokeh applications
io_loop=loop, # Tornado IOLoop
**server_kwargs # port, num_procs, etc.
)
# start timers and services and immediately return
server.start()
bigreddot is correct, but the commands given there won't start a bokeh server by itself; bigreddot是正确的,但那里给出的命令不会自行启动散景服务器; you'll need an existing Tornado server running;
你需要一个现有的 Tornado 服务器运行; so here's a standalone solution given in bokeh's docs in the same section :-
所以这里有一个独立的解决方案,在同一部分的bokeh 文档中给出:-
Here's the relevant section that starts the server.这是启动服务器的相关部分。 For the complete example refer to the example code from bokeh's documentation
有关完整示例,请参阅 bokeh 文档中的示例代码
server = Server({'/': bkapp}, num_procs=4)
server.start()
if __name__ == '__main__':
print('Opening Bokeh application on http://localhost:5006/')
server.io_loop.add_callback(server.show, "/")
server.io_loop.start()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.