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

时间:2019-12-16 06:05:02

标签: bokeh 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

当然,这是错误的,因为它与龙卷风应用程序有关,而不是与Bokeh服务器有关,那么,我该怎么做Bokeh服务器呢?

1 个答案:

答案 0 :(得分:0)

几乎所有支持开发模式的代码(即监视列表文件文件和自动重载)都在Bokeh服务器的应用程序部分中,而不是在库中。因此,您基本上需要在此处复制代码:

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