Share a Bokeh plot
Bokeh has two modes and only one of them travels. A Bokeh server app has a Python process behind every widget callback. A Bokeh standalone document is one HTML file that carries its own data and its own JavaScript — it works from any static host, or from an email attachment, or from nowhere, which is where most of them end up.
Publishing the standalone file is the whole trick. The catch is which copy of BokehJS the file asks for.
Publish it
from bokeh.plotting import figure, save
from bokeh.resources import INLINE
import requests, os
p = figure(title="Latency p95", x_axis_type="datetime")
p.line(df["ts"], df["p95"])
save(p, filename="plot.html", resources=INLINE, title="Latency p95")
requests.post(
"https://commareports.com/api/v1/reports",
headers={"Authorization": f"Bearer {os.environ['COMMA_API_TOKEN']}"},
json={"title": "Latency p95", "html": open("plot.html").read()},
).raise_for_status()
resources=INLINE is the load-bearing argument. Bokeh's default writes a
<script src> pointing at cdn.bokeh.org, and report HTML in Comma runs
inside a sandboxed iframe whose script sources are limited to jsdelivr,
unpkg, cdnjs and esm.sh. Inlining sidesteps the question entirely and makes
the file reproducible three years from now, when that CDN has moved on.