{"id":13780619,"url":"https://github.com/lllama/starlette-htmx","last_synced_at":"2025-04-26T06:31:01.313Z","repository":{"id":112704308,"uuid":"450495449","full_name":"lllama/starlette-htmx","owner":"lllama","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-21T22:37:08.000Z","size":3,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T01:27:12.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lllama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-01-21T13:09:52.000Z","updated_at":"2024-05-11T15:47:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"d99a730b-54a0-46ed-8cc7-1f41bae9ffb0","html_url":"https://github.com/lllama/starlette-htmx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lllama%2Fstarlette-htmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lllama%2Fstarlette-htmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lllama%2Fstarlette-htmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lllama%2Fstarlette-htmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lllama","download_url":"https://codeload.github.com/lllama/starlette-htmx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250943986,"owners_count":21511669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:01:17.919Z","updated_at":"2025-04-26T06:31:00.693Z","avatar_url":"https://github.com/lllama.png","language":"Python","funding_links":[],"categories":["Third Party Packages 📦 \u003ca name = \"tools\"\u003e\u003c/a\u003e"],"sub_categories":["Helper Libraries"],"readme":"# Starlette_htmx\n\nA set of extensions for using [HTMX](https://htmx.org) with [Starlette](http://starlette.io).\n\nBased on [django-htmx](https://github.com/adamchainz/django-htmx) by [Adam Johnson](https://github.com/adamchainz)\n\n## Middleware\n\nUsage:\n\n```python\nfrom starlette.middleware import Middleware\nfrom starlette_htmx.middleware import HtmxMiddleware\n\napp = Starlette(debug=True, ..., middleware=[Middleware(HtmxMiddleware)])\n```\n\nThe request objects will then have a `request.state.htmx` object which you can\nuse to test whether the request was made by htmx.\n\n\nThis class provides shortcuts for reading the htmx-specific `request headers \u003chttps://htmx.org/reference/#request_headers\u003e`__.\n\n### `__bool__(): bool`\n\n`True` if the request was made with htmx, otherwise `False`.\nThis is based on the presence of the `HX-Request` header.\n\nThis allows you to switch behaviour for requests made with htmx like so:\n\n```python\n\n    def my_view(request):\n        if request.htmx:\n            template_name = \"partial.html\"\n        else:\n            template_name = \"complete.html\"\n        return render(template_name, ...)\n```\n\n### `boosted: bool`\n\n`True` if the request came from an element with the `hx-boost` attribute.\nBased on the `HX-Boosted` header.\n\n### `current_url: str | None`\n\nThe current URL of the browser, or `None` for non-htmx requests.\nBased on the `HX-Current-URL` header.\n\n### `history_restore_request: bool`\n\n`True` if the request is for history restoration after a miss in the local history cache.\nBased on the `HX-History-Restore-Request` header.\n\n### `prompt: str | None`\n\nThe user response to `hx-prompt \u003chttps://htmx.org/attributes/hx-prompt/\u003e`__ if it was used, or `None`.\n\n### `target: str | None`\n\nThe `id` of the target element if it exists, or `None`.\nBased on the `HX-Target` header.\n\n### `trigger: str | None`\n\nThe `id` of the triggered element if it exists, or `None`.\nBased on the `HX-Trigger` header.\n\n### `trigger_name: str | None`\n\nThe `name` of the triggered element if it exists, or `None`.\nBased on the `HX-Trigger-Name` header.\n\n### `triggering_event: Any | None`\n\nThe deserialized JSON representtation of the event that triggered the request if it exists, or `None`.\nThis header is set by the `event-header htmx extension\n\u003chttps://htmx.org/extensions/event-header/\u003e`__, and contains details of the DOM\nevent that triggered the request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flllama%2Fstarlette-htmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flllama%2Fstarlette-htmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flllama%2Fstarlette-htmx/lists"}