Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing #29 #30

Merged
merged 3 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ A minimal working example.

.. code-block:: python

from flask import Flask
from flask import Flask, render_template
from flask_htmx import HTMX

app = Flask(__name__)
Expand Down
3 changes: 3 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from functools import partial
from flask import Flask, render_template
from flask_htmx import HTMX
from flask_htmx.responses import HTMXResponseClientRedirect
Expand All @@ -8,6 +9,8 @@

@app.route("/")
def home():
if htmx:
return render_template("partials/thing.html")
return render_template("index.html")


Expand Down
46 changes: 28 additions & 18 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
<html lang="en">
<head>
<title>title</title>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<title>title</title>

<!-- Bootstrap5 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Bootstrap5 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<!-- HTMX -->
<script src="https://unpkg.com/[email protected]"></script>
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>

<!-- Alpine.js -->
<script src="//unpkg.com/alpinejs" defer></script>
</head>
<!-- HTMX -->
<script src="https://unpkg.com/[email protected]"></script>

<!-- Alpine.js -->
<script src="//unpkg.com/alpinejs" defer></script>
</head>

<body id="body">
<div id="app" class="">
<button hx-get="/redirect">Home</button>
</div>
<div id="app" class="">
<button hx-get="/partial" hx-target="#partial">Load Partial</button>
</div>

<div id="partial"></div>
</body>

<body id="body">
<div id="app" class="">
<button hx-get="/redirect">Home</button>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions templates/partials/thing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Partial html <b>content</b> loaded after clicking button
Loading