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.ignore_dirs: Sequence[str]| None
: Directory names to ignore. (example)ignore_entity_patterns: Sequence[str]| None
: File/Directory name patterns to ignore (example).
from pathlib import Path
from 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 BrowserReloadPlugin
templates_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:
<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
Close
Hashes for litestar_browser_reload-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05b73c7bccb0a653bd64d51453651f422a8e0623e1582e423b3611a49763de12 |
|
MD5 | 98f4e8690cf9b304b34c605aa276178a |
|
BLAKE2b-256 | c8f45d0cb98187c9e1b29132a4d70ed43749e7f5ab4c0dca095eeb5643c2d317 |
Close
Hashes for litestar_browser_reload-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c27e666fc79ec4693996d5bf33c0e479dde6981ade5e73e15598e8cf2926a50d |
|
MD5 | 47032caf89938a16c0a55e13402f283c |
|
BLAKE2b-256 | ee6010a6616795608f239c08379e66e81cceb845bafe8d51ea02b668dcf1307d |