Quickstart
A complete app that charges money, in one file.
class=com># app.py
class=kw>from larz class=kw>import Larz, Response
class=kw>import larz.money as money
app = Larz(secret="dev-secret")
money.enable(app) class=com># MockProvider in dev โ no keys needed
@app.get("/")
class=kw>def home(req):
class=kw>return "<h1>Home</h1><a href=&class=com>#x27;/pro'>Go Pro</a>"
@app.paid("$9") class=com># one-off unlock
@app.get("/pro")
class=kw>def pro(req):
class=kw>return "<h1>Unlocked for " + req.subject + "</h1>"
@app.metered("$0.02/call") class=com># per-call billing class=kw>from prepaid credit
@app.post("/api/do")
class=kw>def do(req):
class=kw>return {"ok": True}
if __name__ == "__main__":
app.run()
Run it and click /pro: an unpaid visitor is sent through checkout, then
served. Larz also auto-serves these pages:
| Path | What it is |
|---|---|
/larz/pricing | your plans + credit packs |
/larz/credits | balance + buy credits |
/larz/account | customer portal (subscriptions, invoices) |
/larz/admin | revenue dashboard |