From 070beb232458729f59555fa24edf87f5920e9010 Mon Sep 17 00:00:00 2001 From: Zohaib Sibte Hassan Date: Mon, 25 Dec 2023 13:36:05 -0800 Subject: [PATCH] Adding example for Sanic --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 6207ea4..564eb98 100644 --- a/README.md +++ b/README.md @@ -75,4 +75,37 @@ def header(account: AccountInfo) -> DOMElement: domx.h1(f"Welcome {account.name}"), hamburger(account) # Reusing another component ) +``` + +### More usage examples: + +Here is an example app Sanic: + +```python +from sanic import Sanic, html +from htmxido import domx as x + +app = Sanic("Pythia") + +@app.post("/clicked") +async def clicked(request): + return html(str( + x.div("Clicked!!!") + )) + +@app.get("/") +async def home(request): + return html(str( + x.html( + x.head( + x.script(src="https://unpkg.com/htmx.org@1.9.9") + ), + x.body( + x.h1("Running htmxido"), + x.div(id="container")( + x.button("Reveal!!!", hxTarget="#container", hxTrigger="click", hxPost="/clicked") + ), + ) + ) + )) ``` \ No newline at end of file