Skip to main content

litestar-browser-reload

PyPI - Version PyPI - Python Version


[!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

Metadata

Release files for litestar-browser-reload 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litestar-browser-reload 0.3.0
File Size Uploaded
litestar_browser_reload-0.3.0.tar.gz 83.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for litestar-browser-reload 0.3.0
File Interpreter ABI Platform
litestar_browser_reload-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 89.5 kB

Release files / litestar_browser_reload-0.3.0.tar.gz

Download URL litestar_browser_reload-0.3.0.tar.gz
Size 83.0 kB
Tags Source
SHA-256 checksum
How to use checksums
85fa3dab9ed9d00a2f6a880914e1184fa5553812728c47cb20e42a489c1f14c7
BLAKE2b-256 checksum
How to use checksums
f79b6cdc16dfba59732ef87ced9aceba9be839c0d250e8a7a7136ae6df124726
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.10

Release files / litestar_browser_reload-0.3.0-py3-none-any.whl

Download URL litestar_browser_reload-0.3.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
379c59973711d7ce8c75f09789b779684973b982f119c76fa29b2543127ea242
BLAKE2b-256 checksum
How to use checksums
fca2b7051a7d2382adade95a29bcd597a6971123b33d783bcf9e548a2f3d8fb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.10

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page