$ req = web.tx.request $if req.method == "GET": <form method=post action=/note> <label><small>Content:</small><br> <textarea name=content style=width:30em></textarea><br> <button>Post</button> </form> $elif req.method == "POST": $ form = web.form("content") $if token := web.tx.user.session.get("token", [None])[0]: $ mp_resp = web.post("https://micro.blog/micropub", $ headers={ $ "Authorization": f"Bearer {token}", $ "Content-Type": "application/x-www-form-urlencoded", $ }, $ data={ $ "h": "entry", $ "content": form.content, $ }) $mp_resp.text <p>Note posted.</p> $else: <p>Your host does not support access tokens.</p> |