litestar-browser-reload


Namelitestar-browser-reload JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummaryAutomatic browser reload plugin for Litestar, designed for development use.
upload_time2024-06-16 06:30:32
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords autoreload browser litestar
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # litestar-browser-reload

[![PyPI - Version](https://img.shields.io/pypi/v/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/litestar-browser-reload.svg)](https://pypi.org/project/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

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

```html
<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](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)
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "litestar-browser-reload",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "autoreload, browser, litestar",
    "author": null,
    "author_email": "Tobi DEGNON <tobidegnon@proton.me>",
    "download_url": "https://files.pythonhosted.org/packages/8e/e9/16111206fb2584b6b0f4002222cb39f76262cb41ed4c282a1d3640399feb/litestar_browser_reload-0.2.2.tar.gz",
    "platform": null,
    "description": "# litestar-browser-reload\n\n[![PyPI - Version](https://img.shields.io/pypi/v/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/litestar-browser-reload.svg)](https://pypi.org/project/litestar-browser-reload)\n\n-----\n\n> [!IMPORTANT]\n> This plugin currently contains minimal features and is a work-in-progress\n\nAutomatic browser reload plugin for Litestar, designed for development use.\n\n## Table of Contents\n\n- [litestar-browser-reload](#litestar-browser-reload)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [License](#license)\n  - [Credits](#credits)\n\n## Installation\n\n```console\npip install litestar-browser-reload\n```\n\n## Usage\n\nParameters of `BrowserReloadPlugin`:\n\n- `watch_paths: Sequence[Union[str, Path]]`: Paths to watch for changes.\n- `ignore_dirs: Sequence[str]| None`: Directory names to ignore. ([example](https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_dirs))\n- `ignore_entity_patterns: Sequence[str]| None`: File/Directory name patterns to ignore ([example](https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_entity_patterns)).\n\n```python\nfrom pathlib import Path\n\nfrom litestar import Litestar\nfrom litestar.contrib.jinja import JinjaTemplateEngine\nfrom litestar.template.config import TemplateConfig\nfrom litestar.response import Template\nfrom litestar_browser_reload import BrowserReloadPlugin\n\ntemplates_path = Path(\"templates\")\nbrowser_reload = BrowserReloadPlugin(watch_paths=(templates_path,))\n\napp = Litestar(\n    route_handlers=[],\n    debug=True,\n    plugins=[browser_reload],\n    template_config=TemplateConfig(\n        directory=templates_path,\n        engine=JinjaTemplateEngine,\n    ),\n)\n\n```\n\nAdd the following to your base template:\n\n```html\n<head>\n    ...\n    {% if request.app.debug %}\n    <script\n        src=\"/__reload__/static/reload-listener.js\"\n        data-worker-script-path=\"/__reload__/static/reload-worker.js\"\n        data-ws-path=\"/__reload__\"\n        defer\n    ></script>\n    {% endif %}\n </head>\n```\n\n## License\n\n`litestar-browser-reload` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n\n\n## Credits\n\nMuch of this was copied from [django-browser-reload](https://github.com/adamchainz/django-browser-reload) and [foxglove](https://github.com/samuelcolvin/foxglove)",
    "bugtrack_url": null,
    "license": null,
    "summary": "Automatic browser reload plugin for Litestar, designed for development use.",
    "version": "0.2.2",
    "project_urls": {
        "Documentation": "https://github.com/Tobi-De/litestar-browser-reload#readme",
        "Issues": "https://github.com/Tobi-De/litestar-browser-reload/issues",
        "Source": "https://github.com/Tobi-De/litestar-browser-reload"
    },
    "split_keywords": [
        "autoreload",
        " browser",
        " litestar"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "873455f0be8817b61060cfafa274453bd23bef87b881b79aa08a753b7f70fad1",
                "md5": "59c66fffa03b44f9b0230f633bd0922c",
                "sha256": "264ba6d22309edba31709a393162116d88f3cb7afcc2f69c4eddae8989e0e5df"
            },
            "downloads": -1,
            "filename": "litestar_browser_reload-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59c66fffa03b44f9b0230f633bd0922c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6436,
            "upload_time": "2024-06-16T06:30:35",
            "upload_time_iso_8601": "2024-06-16T06:30:35.078265Z",
            "url": "https://files.pythonhosted.org/packages/87/34/55f0be8817b61060cfafa274453bd23bef87b881b79aa08a753b7f70fad1/litestar_browser_reload-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8ee916111206fb2584b6b0f4002222cb39f76262cb41ed4c282a1d3640399feb",
                "md5": "1216a7e72a63ace28cf9499aa7216835",
                "sha256": "a71c3f09dfa46c838d43b3c915a9aa0236067d64a47b183350220f71c5c18e32"
            },
            "downloads": -1,
            "filename": "litestar_browser_reload-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1216a7e72a63ace28cf9499aa7216835",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8958,
            "upload_time": "2024-06-16T06:30:32",
            "upload_time_iso_8601": "2024-06-16T06:30:32.927267Z",
            "url": "https://files.pythonhosted.org/packages/8e/e9/16111206fb2584b6b0f4002222cb39f76262cb41ed4c282a1d3640399feb/litestar_browser_reload-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-16 06:30:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Tobi-De",
    "github_project": "litestar-browser-reload#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "litestar-browser-reload"
}
        
Elapsed time: 1.42067s