Litestar Granian Plugin

raw JSON →
0.15.0 verified Fri May 01 auth: no python

Granian plugin for Litestar, providing a CLI command to run Litestar apps with the Granian ASGI/RSGI server. Version 0.15.0 exposes Granian commands directly through the Litestar CLI. Release cadence is irregular.

pip install litestar-granian
error ModuleNotFoundError: No module named 'litestar_granian'
cause The library is not installed.
fix
Run pip install litestar-granian to install it.
error AttributeError: module 'litestar_granian' has no attribute 'LitestarGranian'
cause Importing incorrectly, possibly as `from litestar_granian import LitestarGranian` but typo or wrong casing.
fix
Use from litestar_granian import LitestarGranian (capital L and G).
breaking Version 0.13.0 removed the process manager. If you relied on `ProcessManager`, upgrade with caution.
fix Migrate to using direct CLI commands instead of `ProcessManager`.
gotcha The CLI parameter for websockets changed from `--websockets` to `--ws` in v0.14.1. Old scripts using `--websockets` will break.
fix Update all CLI invocations to use `--ws` instead of `--websockets`.

Create a Litestar app and serve it with the Granian plugin.

from litestar import Litestar
from litestar_granian import LitestarGranian

app = Litestar()

if __name__ == "__main__":
    # Run using the plugin's CLI or directly via Granian
    LitestarGranian(app).run()