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¶
Trueif the request came from an element with the hx-boost attribute.Based on the
HX-Boostedheader.
- property current_url: Optional[str]¶
The current URL of the browser, or
Nonefor non-HTMX requests.Based on the
HX-Current-URLheader.
- property history_restore_request: bool¶
Trueif the request is for history restoration after a miss in the local history cache.Based on the
HX-History-Restore-Requestheader.
- 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.