The HTMX Class¶
- class flask_htmx.htmx.HTMX(app: Optional[flask.app.Flask] = None)[source]¶
Flask-HTMX is a Flask extension which provides an easy API to work with HTMX from within a Flask request context.
Inspired by the Django extension Django-HTMX.
See also:
- property boosted: bool¶
True
if the request came from an element with the hx-boost attribute.Based on the
HX-Boosted
header.
- property current_url: Optional[str]¶
The current URL of the browser, or
None
for non-HTMX requests.Based on the
HX-Current-URL
header.
- property history_restore_request: bool¶
True
if the request is for history restoration after a miss in the local history cache.Based on the
HX-History-Restore-Request
header.
- init_app(app: flask.app.Flask)[source]¶
Initialise the extension with the Flask app object.
- property target: Optional[str]¶
The ID of the target element if it exists, or
None
.Based on the
HX-Target header
.