Some additional HTML layer stuff.
This commit is contained in:
parent
d6ba934955
commit
026f7aff64
8 changed files with 302 additions and 114 deletions
|
|
@ -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__":
|
||||
|
|
|
|||
17
example_app/templates/demo.html
Normal file
17
example_app/templates/demo.html
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue