Export

Export any webwrench page to a self-contained HTML file. The output includes all JavaScript (bitwrench + Chart.js) inline — no server needed to view it.

Basic Export

import webwrench as ww

ww.title("Quarterly Report")
ww.chart([42, 58, 33, 71], type="bar", labels=["Q1", "Q2", "Q3", "Q4"])
ww.table([
    ["Metric", "Value"],
    ["Revenue", "$1.2M"],
    ["Users", "15,000"],
])

ww.export("report.html")

Open report.html in any browser. Everything is embedded.

Export as String

Get the HTML as a string instead of writing to a file:

html = ww.export_string(title="My Report")
# Use html in an email, API response, etc.

Minified Output

ww.export("report.html", minify=True)

Custom Title

ww.export("report.html", title="Q1 2025 Sales Report")

Browser-Side Features

These functions generate bwserve messages for the browser and work only during a live serve() session:

Screenshot

ww.screenshot("dashboard.png")

PDF Export

ww.export_pdf("report.pdf")

File Download

ww.download("data.csv", content="name,value\nA,1\nB,2")
Tip: export() and export_string() work without a running server. screenshot(), export_pdf(), and download() require a live browser session.