helloworld / code /build_single.py
eduzrh's picture
Upload code/build_single.py with huggingface_hub
64377a9 verified
Raw History Blame Contribute Delete
537 Bytes
"""把 demo 打包成单文件 HTML(内联 CSS/JS/数据)。"""
import pathlib
base = pathlib.Path(__file__).parent
html = (base / "demo/index.html").read_text()
app = (base / "demo/app.js").read_text()
data = (base / "demo/data.js").read_text()
html = html.replace('<script src="data.js"></script>', "<script>\n" + data + "\n</script>")
html = html.replace('<script src="app.js"></script>', "<script>\n" + app + "\n</script>")
out = base / "demo/cdhe-monitor.html"
out.write_text(html)
print(out, round(len(html) / 1e6, 2), "MB")