如何在开发/调试模式下以编程方式启动 Bokeh 服务器

How to start Bokeh server programmatically in dev / debug mode

我仍在开发我的项目,我想通过 HTML/CSS 对 UI 进行大量更改,我正在以编程方式启动 Bokeh 服务器,它看起来像这样:

from tornado.ioloop import IOLoop
from tornado.web import StaticFileHandler
from bokeh.server.server import Server
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from os.path import dirname, join
import sys
if not dirname(__file__) in sys.path: sys.path.append(dirname(__file__))
from models.ProjectDataLoading import modify_page1
from models.Empty import modify_page2

page1_app = Application(FunctionHandler(modify_page1))
page2_app = Application(FunctionHandler(modify_page2))
StaticFileHandler.reset()
io_loop = IOLoop.current()

server = Server(applications = {'/ProjectDataLoading': page1_app,
                                '/PrimaveraObjects': page2_app,
                                '/SpecializedReports': page2_app,
                                '/StatisticalReports': page2_app,
                                '/Predictions': page2_app},
                                extra_patterns=[(r'/static/css/(.*)', StaticFileHandler, {'path':join(dirname(__file__),"static","css")})],
                                io_loop = io_loop, port = 5006, static_hash_cache=False, debug=True, autoreload=True, compiled_template_cache=False, serve_traceback=True)

server.start()
server.show('/ProjectDataLoading')
io_loop.start() 

我仍在处理第 1 页 -> "ProjectDataLoading",如您所见,我正在尝试使用以下代码让服务器停止兑现静态文件:

StaticFileHandler.reset()
static_hash_cache=False
debug=True

当然是错的,因为是tornado应用相关,不是Bokeh server,那么,Bokeh server怎么办呢?

几乎所有支持开发模式的代码,即观看列表文件文件和自动重新加载,都在 Bokeh 服务器的应用程序部分,而不是在库中。因此,您需要在此处重现代码:

https://github.com/bokeh/bokeh/blob/8f9cf0a85ba51098da2d027150e900bfc073eeba/bokeh/command/subcommands/serve.py#L785-L816