asgi-tools -- Is a really lightweight ASGI Toolkit to build ASGI applications faster.
Documentation is here: https://klen.github.io/asgi-tools
ASGI-Tools is designed to be used as an ASGI Toolkit to quickly build really lightweight ASGI applications/middlewares/tools.
For instance these middlewares were built with the library:
Features:
- Supports all most popular async python libraries: Asyncio, Trio and Curio
- Request -- Parse ASGI scope, get url, headers, cookies, read a request's data/json/form-data
- Response -- Send HTTP (text, html, json, stream, sse, file, http errors) responses
- ResponseWebsocket -- Work with websockets
- RequestMiddleware -- Parse a scope and insert the parsed request into the scope
- ResponseMiddleware -- Parse responses and convert them into ASGI messages
- RouterMiddleware -- Route HTTP requests
- LifespanMiddleware -- Process a lifespan cycle
- StaticFilesMiddleware -- Serve static files from URL prefixes
- asgi_tools.tests.TestClient -- A test client with websockets support to test asgi applications
- App -- A simple foundation for ASGI apps
- python >= 3.9
Note
pypy3 is also supported
ASGI-Tools belongs to the category of ASGI web frameworks, so it requires an ASGI HTTP server to run, such as uvicorn, daphne, or hypercorn.
asgi-tools should be installed using pip:
pip install asgi-tools
You can use any of ASGI-Tools components independently.
Dispite this ASGI-Tools contains App helper to quickly build ASGI applications. For instance:
Save this to app.py
.
from asgi_tools import App
app = App()
@app.route('/')
async def hello(request):
return "Hello World!"
Run it with uvicorn
$ uvicorn app:app
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/asgi-tools/issues
Development of the project happens at: https://github.com/klen/asgi-tools
Licensed under a MIT license.