Skip to main content

Powerful and exquisite WSGI/ASGI framework/toolkit.

Project description

BáiZé

Codecov PyPI - Python Version

Powerful and exquisite WSGI/ASGI framework/toolkit. Use MyPyC to improve code running speed.

The minimize implementation of methods required in the Web framework. No redundant implementation means that you can freely customize functions without considering the conflict with baize's own implementation.

Under the ASGI/WSGI protocol, the interface of the request object and the response object is almost the same, only need to add or delete await in the appropriate place. In addition, it should be noted that ASGI supports WebSocket but WSGI does not.

Install

pip install -U baize

Or install from GitHub master branch

pip install -U git+https://github.com/abersheeran/baize@setup.py

Document and other website

BáiZé Document

If you have questions or idea, you can send it to Discussions.

Quick Start

A short example for WSGI application, if you don't know what is WSGI, please read PEP3333.

from baize.wsgi import request_response, Router, Request, Response, PlainTextResponse


@request_response
def sayhi(request: Request) -> Response:
    return PlainTextResponse("hi, " + request.path_params["name"])


@request_response
def echo(request: Request) -> Response:
    return PlainTextResponse(request.body)


application = Router(
    ("/", PlainTextResponse("homepage")),
    ("/echo", echo),
    ("/sayhi/{name}", sayhi),
)


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(application, interface="wsgi", port=8000)

A short example for ASGI application, if you don't know what is ASGI, please read ASGI Documention.

from baize.asgi import request_response, Router, Request, Response, PlainTextResponse


@request_response
async def sayhi(request: Request) -> Response:
    return PlainTextResponse("hi, " + request.path_params["name"])


@request_response
async def echo(request: Request) -> Response:
    return PlainTextResponse(await request.body)


application = Router(
    ("/", PlainTextResponse("homepage")),
    ("/echo", echo),
    ("/sayhi/{name}", sayhi),
)


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(application, interface="asgi3", port=8000)

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baize-0.11.0.tar.gz (33.5 kB view hashes)

Uploaded Source

Built Distributions

baize-0.11.0-py3-none-any.whl (36.6 kB view hashes)

Uploaded Python 3

baize-0.11.0-cp39-cp39-win_amd64.whl (220.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

baize-0.11.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

baize-0.11.0-cp39-cp39-macosx_10_14_x86_64.whl (273.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

baize-0.11.0-cp38-cp38-win_amd64.whl (188.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

baize-0.11.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (944.8 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

baize-0.11.0-cp38-cp38-macosx_10_14_x86_64.whl (231.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

baize-0.11.0-cp37-cp37m-win_amd64.whl (186.7 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

baize-0.11.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (837.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

baize-0.11.0-cp37-cp37m-macosx_10_14_x86_64.whl (225.4 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

baize-0.11.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (808.4 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

baize-0.11.0-cp36-cp36m-macosx_10_14_x86_64.whl (220.3 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page