Skip to main content

Granian plugin for Litestar

Project description

Litestar Granian Plugin

Installation

pip install litestar-granian

Usage

Here is a basic application that demonstrates how to use the plugin.

from __future__ import annotations

from litestar import Controller, Litestar, get

from litestar_granian import GranianPlugin


class SampleController(Controller):
    @get(path="/sample")
    async def sample_route(self ) -> dict[str, str]:
        """Sample Route."""
        return {"sample": "hello-world"}


app = Litestar(plugins=[GranianPlugin()], route_handlers=[SampleController])

Now, you can use the standard Litestar CLI and it will run with Granian instead of Uvicorn.

 litestar --app examples.basic:app run
Using Litestar app from env: 'examples.basic:app'
Starting granian server process ──────────────────────────────────────────────
┌──────────────────────────────┬──────────────────────┐
│ Litestar version              2.1.1                │
│ Debug mode                    Disabled             │
│ Python Debugger on exception  Disabled             │
│ CORS                          Disabled             │
│ CSRF                          Disabled             │
│ OpenAPI                       Enabled path=/schema │
│ Compression                   Disabled             │
└──────────────────────────────┴──────────────────────┘
[INFO] Starting granian
[INFO] Listening at: 127.0.0.1:8000
[INFO] Spawning worker-1 with pid: 2719082
[INFO] Started worker-1
[INFO] Started worker-1 runtime-1

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_granian-0.5.1.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

litestar_granian-0.5.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file litestar_granian-0.5.1.tar.gz.

File metadata

  • Download URL: litestar_granian-0.5.1.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for litestar_granian-0.5.1.tar.gz
Algorithm Hash digest
SHA256 0aa065e09caf12820940f05c8f30336a4f0082d9bfd87db8eefd85471212c54d
MD5 145e61ce5efa1ae550d7f9fff9d90a94
BLAKE2b-256 24c1e8954803c339b49c66d1678b638acccc1e2798332d721323f1045d065e2e

See more details on using hashes here.

File details

Details for the file litestar_granian-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_granian-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc4119df32b137167aa2ef1a9e51d3237c908ff710d0ae4dacfa7f80667131ff
MD5 15aa359b567d90686c0b2c935694216a
BLAKE2b-256 5234ff388a155e3d8daf4391ef3f80c966a1605332f8d20d728e7e3d6817df96

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