Reference: app, routing, request/response
The Larz app object and its decorators.
Larz(...)
Larz(secret="...", name="app", debug=False, templates=None)
@app.route(pattern, methods) | register a route |
@app.get/post(pattern) | method shortcuts |
@app.paid(price, sku, days, trial_days, plan) | paywall (needs money) |
@app.metered(price, sku) | per-call billing |
@app.plan(name) | gate on a plan |
@app.login_required / @app.require_role(r) | auth (needs auth) |
@app.api_key_required(plan=) | API-key gate |
@app.validate(schema) | request validation (needs api) |
@app.cache(ttl) / @app.job / @app.schedule(cron) | ops |
app.use(mw) | attach middleware |
app.static(url, dir) | serve static files |
app.register(blueprint) | mount a Blueprint |
app.render(name, **ctx) | render a template |
app.run(host, port) | dev server (use gunicorn in prod) |
Request
req.method · req.path · req.query · req.params · req.form · req.json() · req.header(k) ·
req.cookies · req.session · req.subject · req.user · req.api_key · req.body
Response
Response(body, status, headers) · Response.json(data, status) · Response.redirect(loc) ·
resp.set_cookie(k, v)
See Routing & requests for usage.