https://github.com/tobi-de/litestar-browser-reload
Automatic browser reload plugin for Litestar, designed for development use.
https://github.com/tobi-de/litestar-browser-reload
litestar litestar-framework
Last synced: 5 months ago
JSON representation
Automatic browser reload plugin for Litestar, designed for development use.
- Host: GitHub
- URL: https://github.com/tobi-de/litestar-browser-reload
- Owner: Tobi-De
- License: mit
- Created: 2024-06-10T10:06:19.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-06-16T07:23:41.000Z (11 months ago)
- Last Synced: 2024-11-09T03:19:28.416Z (6 months ago)
- Topics: litestar, litestar-framework
- Language: Python
- Homepage: https://github.com/Tobi-De/litestar-browser-reload
- Size: 29.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# litestar-browser-reload
[](https://pypi.org/project/litestar-browser-reload)
[](https://pypi.org/project/litestar-browser-reload)-----
> [!IMPORTANT]
> This plugin currently contains minimal features and is a work-in-progressAutomatic 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.
- `ignore_dirs: Sequence[str]| None`: Directory names to ignore. ([example](https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_dirs))
- `ignore_entity_patterns: Sequence[str]| None`: File/Directory name patterns to ignore ([example](https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_entity_patterns)).```python
from pathlib import Pathfrom litestar import Litestar
from litestar.contrib.jinja import JinjaTemplateEngine
from litestar.template.config import TemplateConfig
from litestar.response import Template
from litestar_browser_reload import BrowserReloadPlugintemplates_path = Path("templates")
browser_reload = BrowserReloadPlugin(watch_paths=(templates_path,))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
...
{% if request.app.debug %}
{% endif %}
```## 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)