A Rust HTTP server for Python applications
Find a file
2023-01-20 01:36:31 +01:00
.github Update CI release workflow 2023-01-20 01:36:31 +01:00
benchmarks Update benchmarks 2023-01-13 02:13:41 +01:00
docs/spec Fix typos (#14) 2022-11-17 08:11:25 +01:00
granian Bump version to 0.2.5 2023-01-19 19:07:54 +01:00
lib/pyo3-asyncio Bump pyo3-asyncio to 0.17 2022-10-25 13:18:02 +02:00
src Fix response headers getting overwritten in ASGI, WSGI protocols (#53) 2023-01-19 19:40:02 +01:00
tests Fix wsgi.input out of spec (close #24) 2023-01-12 21:13:31 +01:00
.gitignore first implementation 2022-04-15 18:45:01 +02:00
build.rs Add PyPy support 2023-01-03 12:52:22 +01:00
Cargo.lock Bump version to 0.2.5 2023-01-19 19:07:54 +01:00
Cargo.toml Bump maturin to 0.14.2 2023-01-19 19:09:56 +01:00
LICENSE first implementation 2022-04-15 18:45:01 +02:00
pyproject.toml Bump maturin to 0.14.2 2023-01-19 19:09:56 +01:00
README.md Update benchmarks results 2022-12-24 18:04:30 +01:00
setup.py review package meta 2022-04-18 20:08:21 +02:00

Granian

A Rust HTTP server for Python applications.

Rationale

The main reasons behind Granian design are:

  • Have a single, correct HTTP implementation, supporting versions 1, 2 (and eventually 3)
  • Provide a single package for several platforms
  • Avoid the usual Gunicorn + uvicorn + http-tools dependency composition on unix systems
  • Provide stable performance when compared to existing alternatives

Features

  • Supports ASGI/3, RSGI and WSGI interface applications
  • Implements HTTP/1 and HTTP/2 protocols
  • Supports HTTPS
  • Supports Websockets over HTTP/1 and HTTP/2

Quickstart

You can install Granian using pip:

$ pip install granian

Create an ASGI application in your main.py:

async def app(scope, receive, send):
    assert scope['type'] == 'http'

    await send({
        'type': 'http.response.start',
        'status': 200,
        'headers': [
            [b'content-type', b'text/plain'],
        ],
    })
    await send({
        'type': 'http.response.body',
        'body': b'Hello, world!',
    })

and serve it:

$ granian --interface asgi main:app

You can also create an app using the RSGI specification:

async def app(scope, proto):
    assert scope.proto == 'http'

    proto.response_str(
        status=200,
        headers=[
            ('content-type', 'text/plain')
        ],
        body="Hello, world!"
    )

and serve it using:

$ granian --interface rsgi main:app

Project status

Granian is currently under active development.

Granian is compatible with Python 3.7 and above versions on unix platforms and 3.8 and above on Windows.

License

Granian is released under the BSD License.