https://github.com/simonw/asgi-debug
Debugging middleware for ASGI applications
https://github.com/simonw/asgi-debug
asgi middleware
Last synced: about 1 year ago
JSON representation
Debugging middleware for ASGI applications
- Host: GitHub
- URL: https://github.com/simonw/asgi-debug
- Owner: simonw
- License: apache-2.0
- Created: 2019-07-08T04:51:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-10T18:22:20.000Z (almost 7 years ago)
- Last Synced: 2024-10-18T07:53:57.321Z (over 1 year ago)
- Topics: asgi, middleware
- Language: Python
- Size: 6.84 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# asgi-debug
[](https://pypi.org/project/asgi-debug/)
[](https://circleci.com/gh/simonw/asgi-debug)
[](https://github.com/simonw/asgi-debug/blob/master/LICENSE)
ASGI middleware for debugging ASGI applications
## Installation
pip install asgi-debug
## Usage
Wrap your application in the middleware like this:
```python
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"}'})
```
When you run the app, debugging information will print to your terminal.
If you save the above in `demo.py` you can `pip install uvicorn` and run it like this:
```
uvicorn demo:hello_world_app
```