Automatic browser reload plugin for Litestar, designed for development use.
Project description
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
Installation
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 to exclude certain directories or patterns.
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:
<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 license.
Credits
Much of this was copied from django-browser-reload and foxglove
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litestar_browser_reload-0.3.0.tar.gz.
File metadata
- Download URL: litestar_browser_reload-0.3.0.tar.gz
- Upload date:
- Size: 83.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85fa3dab9ed9d00a2f6a880914e1184fa5553812728c47cb20e42a489c1f14c7
|
|
| MD5 |
f0fa632a9486e302240b4580d274edff
|
|
| BLAKE2b-256 |
f79b6cdc16dfba59732ef87ced9aceba9be839c0d250e8a7a7136ae6df124726
|
File details
Details for the file litestar_browser_reload-0.3.0-py3-none-any.whl.
File metadata
- Download URL: litestar_browser_reload-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
379c59973711d7ce8c75f09789b779684973b982f119c76fa29b2543127ea242
|
|
| MD5 |
79dbde54d2b70750720786791557a664
|
|
| BLAKE2b-256 |
fca2b7051a7d2382adade95a29bcd597a6971123b33d783bcf9e548a2f3d8fb0
|