一个用于 Python 应用程序的 Rust HTTP 服务器
面向 Python 的 Rust HTTP 服务器
Granian 是一个基于 Hyper 和 Tokio 构建的、面向 Python 应用程序的 Rust HTTP 服务器。
Granian 设计背后的主要原因是:
因此,在以下情况下,采用 Granian 将是一个不错的选择:
另一方面,Granian 并非理想选择的情况:
trio 或 gevent你可以使用 pip 安装 Granian:
$ pip install granian在你的 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!',
})然后使用 Granian CLI 来提供服务:
$ granian --interface as暂无开放 Issues,或尚未同步最近议题。