Results#
- class Document(html: str)[source]#
A rendered page, from
Page.str(document)is the HTML.Example
>>> from anza import Page, Setup >>> doc = Page("/", {"title": "Hi"}).run(Setup(root="templates").run()) >>> str(doc) == doc.html True >>> doc.to_bytes()[:12] b'<html><body>'
- class Envelope(slot: str, ts: int, html: str, sig: str | None = None, css: str | None = None, v: int = 2)[source]#
A rendered fragment on the wire, envelope format v2.
Produced by
Fragment. The JSON form is{"v":2,"slot":...,"ts":...,"html":...,"sig":...}(sigandcssonly when set), byte-identical to the Rust and TypeScript engines (see the Engine Contract).Example
>>> from anza import Envelope >>> env = Envelope(slot="feed", ts=1700000000, html="<p>Hi</p>") >>> env.to_json() '{"v":2,"slot":"feed","ts":1700000000,"html":"<p>Hi</p>"}' >>> env.to_dict()["v"] 2
- sig: str | None = None#
Lowercase-hex signature over
message(), orNonewhen the engine does not sign.
- message() bytes[source]#
The exact bytes the signature covers.
- Returns:
bytes –
signature_message(ts, slot, html, css), seesignature_message().
- class Manifest(templates: dict[str, str] = ...)[source]#
Template names mapped to the SHA-256 digest of their source.
Build one with
CacheStore.manifest()to compare template versions across servers or deployments.Example
>>> from anza import Manifest >>> m = Manifest() >>> m.insert("feed/card.html", "ab12") >>> m.get("feed/card.html"), m.get("other.html") ('ab12', None)