Some additional HTML layer stuff.

This commit is contained in:
Yaro Kasear 2025-08-26 15:30:55 -05:00
parent d6ba934955
commit 026f7aff64
8 changed files with 302 additions and 114 deletions

View file

@ -18,6 +18,9 @@ def create_app():
Base.metadata.create_all(engine)
app.register_blueprint(make_json_blueprint(session_factory, registry), url_prefix="/api")
app.register_blueprint(make_fragments_blueprint(session_factory, registry), url_prefix="/ui")
@app.get("/demo")
def demo():
return render_template("demo.html")
return app
if __name__ == "__main__":

View file

@ -0,0 +1,17 @@
<!-- templates/demo.html -->
<!doctype html><meta charset="utf-8">
<script src="https://unpkg.com/htmx.org@2.0.0"></script>
<body>
<table class="table-auto w-full border">
<thead><tr><th class="px-3 py-2">ID</th><th class="px-3 py-2">Title</th><th class="px-3 py-2">Author</th><th></th></tr></thead>
<tbody id="rows"
hx-get="/ui/book/frag/rows?fields_csv=id,title,author.name&page=1&per_page=20"
hx-trigger="load" hx-target="this" hx-swap="innerHTML"></tbody>
</table>
<button hx-get="/ui/book/frag/form?hx=1&fields_csv=id,title,author.name"
hx-target="#modal-body" hx-swap="innerHTML"
onclick="document.getElementById('modal').showModal()">New Book</button>
<dialog id="modal"><div id="modal-body"></div></dialog>
</body>