跳转到主要内容

用于调试ASGI应用程序的ASGI中间件

项目描述

asgi-debug

PyPI CircleCI License

用于调试ASGI应用程序的ASGI中间件

安装

pip install asgi-debug

用法

像这样将您的应用程序包装在中间件中

from asgi_debug import asgi_debug_decorator


@asgi_debug_decorator()
async def hello_world_app(scope, receive, send):
    assert scope["type"] == "http"
    await send(
        {
            "type": "http.response.start",
            "status": 200,
            "headers": [[b"content-type", b"application/json"]],
        }
    )
    await send({"type": "http.response.body", "body": b'{"hello": "world"}'})

当您运行应用程序时,调试信息将打印到您的终端。

如果您将上述内容保存在demo.py中,您可以使用pip install uvicorn并按如下方式运行它

uvicorn demo:hello_world_app

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分布

此版本没有可用的源代码分布文件。请参阅生成分布存档的教程

构建分布

asgi_debug-0.1-py3-none-any.whl (6.2 kB 查看散列)

上传时间: Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面