You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Bokeh仪表盘的静态文件服务端点路径?

Adjusting Bokeh Static File Path for Per-Dashboard Prefixes

Absolutely! You can fix this static file path issue and avoid the separate static server + version mismatch problems by configuring each Bokeh dashboard server to use its own prefix for static resources. Here's how to implement this step-by-step:

1. Set the Root URL for Each Bokeh Server Instance

The key is to tell each Bokeh Server what its public-facing root URL is, so it generates static resource paths relative to that prefix. When starting each dashboard's Bokeh Server, use the --root-url parameter to specify the full prefix path:

# For dashboard1
bokeh serve --root-url=https://myloadbalancer/dashboard1/ dashboard1_app.py

# For dashboard2
bokeh serve --root-url=https://myloadbalancer/dashboard2/ dashboard2_app.py

This tells Bokeh to generate all static resource references (like JS/CSS files) using the provided root URL as the base. So instead of pointing to /static, the requests will go to https://myloadbalancer/dashboard1/static and https://myloadbalancer/dashboard2/static respectively.

2. Verify the Static Path Changes

After launching the servers, visit one of your dashboards (e.g., https://myloadbalancer/dashboard1) and open your browser's developer tools. Check the Network tab—you should see all Bokeh static assets being requested from the /dashboard1/static/ path instead of the root /static.

3. Confirm Load Balancer Routing

Make sure your load balancer is configured to forward requests for https://myloadbalancer/{dashboard_name}/** (including the static subpath) to the corresponding Bokeh Server instance. If you already have routing set up for the dashboard itself, this should work automatically since /dashboard_name/static is a subpath of the existing route.

Bonus: Code-Level Configuration (If Needed)

If you're embedding Bokeh in another framework (like Flask/Django) or need to set the root URL programmatically in your app code, you can adjust the root_url setting directly in your Bokeh document:

from bokeh.plotting import curdoc

curdoc().settings.root_url = "https://myloadbalancer/dashboard1/"

This achieves the same effect as the command-line parameter, but is useful if you need dynamic configuration.

I’ve used this exact approach in a multi-Bokeh-instance load-balanced setup before, and it completely eliminated the need for a shared static server while resolving version conflicts between different dashboards.

内容的提问来源于stack exchange,提问作者Arran Duff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 06:32:53