Skip to main content

Automatic browser reload plugin for Litestar, designed for development use.

Project description

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.
  • 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

litestar_browser_reload-0.2.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

litestar_browser_reload-0.2.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file litestar_browser_reload-0.2.2.tar.gz.

File metadata

File hashes

Hashes for litestar_browser_reload-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a71c3f09dfa46c838d43b3c915a9aa0236067d64a47b183350220f71c5c18e32
MD5 1216a7e72a63ace28cf9499aa7216835
BLAKE2b-256 8ee916111206fb2584b6b0f4002222cb39f76262cb41ed4c282a1d3640399feb

See more details on using hashes here.

File details

Details for the file litestar_browser_reload-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_browser_reload-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 264ba6d22309edba31709a393162116d88f3cb7afcc2f69c4eddae8989e0e5df
MD5 59c66fffa03b44f9b0230f633bd0922c
BLAKE2b-256 873455f0be8817b61060cfafa274453bd23bef87b881b79aa08a753b7f70fad1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page