Yaat

Yet another ASGI toolkit

travis status docs status codecov report pypi package version Code style: black


Introduction

Yaat is an asynchronous web toolkit. It is as simple as...

from yaat import Yaat
from yaat.responses import TextResponse

app = Yaat()

@app.route("/")
async def index(request):
    return TextResponse("Hello World")

Features

  • Provide decorator routes & class-based views.
  • Template support with Jinja2.
  • Static file serving.
  • HTTP streaming response.
  • Cookie support.
  • WebSocket support.
  • API schema generator and Swagger UI.
  • Background tasks runner.
  • Server startup and shutdown events.
  • CORS support.
  • Test client using httpx.

Yaat supports the loose coding style. It does not force any solution, and how the project should be structured is decided by the developer.

Requirements

Python 3.6+

Installation

pip3 install yaat

To run the application, you will need an ASGI server. Such as uvicorn, hypercorn or daphne.

For example, if you put the example code from the top in app.py. You can run the application by

uvicorn app:app

you can check out complete examples in Yaat Examples section.

Dependencies

  • aiofiles - to read files for FileResponse or StaticFiles.
  • httpx - for test client.
  • Jinja2 - to use Jinja2Template for template responses.
  • parse - for parsing path parameters.
  • python-multipart - for form parser, request.form().
  • PyYAML - for schema generator.

License

Yaat is licensed under GNU Lesser General Public License.

Inspiration

I know there are a lot of awesome frameworks out there. So some might ask why did I write my own. Actually, I created this to learn how the web framework works.

I started this after following Jahongir Rahmonov's blog post about writing a web framework. Feel free to check out his WSGI framework Alcazar.

More features will be added in the future. You can check out the project board.