Name | litestar-browser-reload JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | Automatic browser reload plugin for Litestar, designed for development use. |
upload_time | 2024-12-21 19:06:18 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
autoreload
browser
litestar
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# litestar-browser-reload
[![PyPI - Version](https://img.shields.io/pypi/v/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)
-----
> [!IMPORTANT]
> This plugin currently contains minimal features and is a work-in-progress
Automatic browser reload plugin for Litestar, designed for development use.
## Table of Contents
- [litestar-browser-reload](#litestar-browser-reload)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)
- [Credits](#credits)
## Installation
```console
pip install litestar-browser-reload
```
## Usage
Parameters of `BrowserReloadPlugin`:
- `watch_paths: Sequence[Union[str, Path]]`: Paths to watch for changes.
- `watch_filter: BaseFilter | None = None`: A [filter](https://watchfiles.helpmanual.io/api/filters/) to exclude certain directories or patterns.
```python
from pathlib import Path
from litestar import Litestar
from litestar.contrib.jinja import JinjaTemplateEngine
from litestar.template.config import TemplateConfig
from litestar_browser_reload import BrowserReloadPlugin
from watchfiles import DefaultFilter
templates_path = Path("templates")
browser_reload = BrowserReloadPlugin(
watch_paths=(Path("templates"),),
watch_filter=DefaultFilter(ignore_dirs=(".git", ".hg", ".svn", ".tox")),
)
app = Litestar(
route_handlers=[],
debug=True,
plugins=[browser_reload],
template_config=TemplateConfig(
directory=templates_path,
engine=JinjaTemplateEngine,
),
)
```
Add the following to your base template:
```html
<head>
...
{% if request.app.debug %}
<script
src="/__reload__/static/reload-listener.js"
data-worker-script-path="/__reload__/static/reload-worker.js"
data-ws-path="/__reload__"
defer
></script>
{% endif %}
</head>
```
## License
`litestar-browser-reload` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
## Credits
Much of this was copied from [django-browser-reload](https://github.com/adamchainz/django-browser-reload) and [foxglove](https://github.com/samuelcolvin/foxglove)
Raw data
{
"_id": null,
"home_page": null,
"name": "litestar-browser-reload",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "autoreload, browser, litestar",
"author": null,
"author_email": "Tobi DEGNON <tobidegnon@proton.me>",
"download_url": "https://files.pythonhosted.org/packages/f7/9b/6cdc16dfba59732ef87ced9aceba9be839c0d250e8a7a7136ae6df124726/litestar_browser_reload-0.3.0.tar.gz",
"platform": null,
"description": "# litestar-browser-reload\n\n[![PyPI - Version](https://img.shields.io/pypi/v/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)\n\n-----\n\n> [!IMPORTANT]\n> This plugin currently contains minimal features and is a work-in-progress\n\nAutomatic browser reload plugin for Litestar, designed for development use.\n\n## Table of Contents\n\n- [litestar-browser-reload](#litestar-browser-reload)\n - [Table of Contents](#table-of-contents)\n - [Installation](#installation)\n - [Usage](#usage)\n - [License](#license)\n - [Credits](#credits)\n\n## Installation\n\n```console\npip install litestar-browser-reload\n```\n\n## Usage\n\nParameters of `BrowserReloadPlugin`:\n\n- `watch_paths: Sequence[Union[str, Path]]`: Paths to watch for changes.\n- `watch_filter: BaseFilter | None = None`: A [filter](https://watchfiles.helpmanual.io/api/filters/) to exclude certain directories or patterns.\n\n```python\nfrom pathlib import Path\n\nfrom litestar import Litestar\nfrom litestar.contrib.jinja import JinjaTemplateEngine\nfrom litestar.template.config import TemplateConfig\nfrom litestar_browser_reload import BrowserReloadPlugin\nfrom watchfiles import DefaultFilter\n\ntemplates_path = Path(\"templates\")\nbrowser_reload = BrowserReloadPlugin(\n watch_paths=(Path(\"templates\"),),\n watch_filter=DefaultFilter(ignore_dirs=(\".git\", \".hg\", \".svn\", \".tox\")),\n)\n\napp = Litestar(\n route_handlers=[],\n debug=True,\n plugins=[browser_reload],\n template_config=TemplateConfig(\n directory=templates_path,\n engine=JinjaTemplateEngine,\n ),\n)\n\n```\n\nAdd the following to your base template:\n\n```html\n<head>\n ...\n {% if request.app.debug %}\n <script\n src=\"/__reload__/static/reload-listener.js\"\n data-worker-script-path=\"/__reload__/static/reload-worker.js\"\n data-ws-path=\"/__reload__\"\n defer\n ></script>\n {% endif %}\n </head>\n```\n\n## License\n\n`litestar-browser-reload` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n\n\n## Credits\n\nMuch of this was copied from [django-browser-reload](https://github.com/adamchainz/django-browser-reload) and [foxglove](https://github.com/samuelcolvin/foxglove)\n",
"bugtrack_url": null,
"license": null,
"summary": "Automatic browser reload plugin for Litestar, designed for development use.",
"version": "0.3.0",
"project_urls": {
"Documentation": "https://github.com/Tobi-De/litestar-browser-reload#readme",
"Issues": "https://github.com/Tobi-De/litestar-browser-reload/issues",
"Source": "https://github.com/Tobi-De/litestar-browser-reload"
},
"split_keywords": [
"autoreload",
" browser",
" litestar"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "fca2b7051a7d2382adade95a29bcd597a6971123b33d783bcf9e548a2f3d8fb0",
"md5": "79dbde54d2b70750720786791557a664",
"sha256": "379c59973711d7ce8c75f09789b779684973b982f119c76fa29b2543127ea242"
},
"downloads": -1,
"filename": "litestar_browser_reload-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "79dbde54d2b70750720786791557a664",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6482,
"upload_time": "2024-12-21T19:06:16",
"upload_time_iso_8601": "2024-12-21T19:06:16.693016Z",
"url": "https://files.pythonhosted.org/packages/fc/a2/b7051a7d2382adade95a29bcd597a6971123b33d783bcf9e548a2f3d8fb0/litestar_browser_reload-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f79b6cdc16dfba59732ef87ced9aceba9be839c0d250e8a7a7136ae6df124726",
"md5": "f0fa632a9486e302240b4580d274edff",
"sha256": "85fa3dab9ed9d00a2f6a880914e1184fa5553812728c47cb20e42a489c1f14c7"
},
"downloads": -1,
"filename": "litestar_browser_reload-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "f0fa632a9486e302240b4580d274edff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 83050,
"upload_time": "2024-12-21T19:06:18",
"upload_time_iso_8601": "2024-12-21T19:06:18.428244Z",
"url": "https://files.pythonhosted.org/packages/f7/9b/6cdc16dfba59732ef87ced9aceba9be839c0d250e8a7a7136ae6df124726/litestar_browser_reload-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-21 19:06:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Tobi-De",
"github_project": "litestar-browser-reload#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "litestar-browser-reload"
}