Powerful and exquisite WSGI/ASGI framework/toolkit.
Project description
BáiZé
Powerful and exquisite WSGI/ASGI framework/toolkit.
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.
- Support range file response, server-sent event response
- Support WebSocket (only ASGI)
- WSGI, ASGI routing to combine any application like Django(wsgi)/Pyramid/Bottle/Flask or Django(asgi)/Index.py/Starlette/FastAPI/Sanic/Quart
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
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.
You can do whatever you want with the permission of the license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for baize-0.10.0rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3344ac07e24330742e45c8b84a482583ba5bf9b3613947044f1c8597b304a8f1 |
|
MD5 | 8d55185e201a6657ed3a881f4419e583 |
|
BLAKE2b-256 | 47c05164a4dcbb6ccbfb27762375c3debdf997dc168dfc46d7856816a75300c4 |
Hashes for baize-0.10.0rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e2555a34c6a6fd4197eb92eb4c3d89ab571590e73a57d4772cf9ed7f694f136 |
|
MD5 | c509d49e8aa11fa97e23412d58c7b50a |
|
BLAKE2b-256 | 7bc6c3f77f7208a2e1a7f7a0e64a8559d311cad8d566557f6e7f8370a82bae48 |
Hashes for baize-0.10.0rc1-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff9b653eb1dd8c9c4bf165d152bf9d6052818e2b23b5a0baabed688cff49d81d |
|
MD5 | 61f69280a07fe167f8a8fe34554c3bb4 |
|
BLAKE2b-256 | 046a462ea57967ad4b16e7ab384bc7479056f656d7c932705d9500bfd5566421 |
Hashes for baize-0.10.0rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f57e064ac3d090bccc448b07424a4131cb369ea49faf7e5d696c92e8019ee1af |
|
MD5 | 52c8a977a495c9e7ddae4a803000f07f |
|
BLAKE2b-256 | 93a4196cf366d1ce6e5a10c09f23ed7abbaf6d1f1d84f0dee6b533d6ef8161d2 |
Hashes for baize-0.10.0rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2a78a9b7d16bcfaae6abe69bafa0bde83be0f484ff66780dbd7e921e1c88246 |
|
MD5 | 1fd98b16c8e624d9644abb63d5747fc9 |
|
BLAKE2b-256 | 8dbf23ac64f0bcb40b0a160fc02a26055556f1853f2a8de03f07c4619f73c2d3 |
Hashes for baize-0.10.0rc1-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48e751221d02cfb07a627decdc8a9df288104b41d09dfe7b7cdbaa8f2febfb8b |
|
MD5 | 5eef9c525d26a332b5b445e7dc882790 |
|
BLAKE2b-256 | 4578e9e0f61a9b79441d7fcef0a39b8be3cd84383e9502a655be95ea07a867bd |
Hashes for baize-0.10.0rc1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb6da5adbb590bd38c1dcce09938409110b57f5476b77fefb4234cd4c58ab00 |
|
MD5 | 2b74ce067dd22ae33f88bf121e18bb3d |
|
BLAKE2b-256 | 5a98ece3d03ee6363fed9ee22c6e5fc875448ef2f65325efbdeb0d954bd1ae3a |
Hashes for baize-0.10.0rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4668a293f094a6696946fb8e689f7d5e10d8b70ff54bc2ba711d6562e80a81b0 |
|
MD5 | 17824af004806e1da077152461ddd1ff |
|
BLAKE2b-256 | 77951ad38cecf8e312795f35700d8806d7aa2af94cda9df0f0e28cacb02df89c |
Hashes for baize-0.10.0rc1-cp37-cp37m-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d87512888aff4f9c8323429831ecb82cb29a52baa698ded95f4c25b1cc00a635 |
|
MD5 | 99732c42394c91e482cb0692d16e3460 |
|
BLAKE2b-256 | 31131dc38096e91b4c6d691a7e1119808e00557313743f9f88227578ed864924 |
Hashes for baize-0.10.0rc1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef0748a066e24faab1232531c99894947c2b4fc493bb69a68869872ebef244d8 |
|
MD5 | 2413f8a177782036785ef1393f4b97d6 |
|
BLAKE2b-256 | 3ad565575a1008c572c4f83f6fcdafa42bbac5e93038dcfcd6bf9f8b3ed17f43 |
Hashes for baize-0.10.0rc1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cebaae72fe05310ef6b0bc1f6ad6b41864592266183c2a174b52623103c74102 |
|
MD5 | b328eb028e7551e1f69d4c9df10cca19 |
|
BLAKE2b-256 | 68b9415f3bcc08ece09e722774c72a63d338f01fa8fbd159d36e848871477111 |
Hashes for baize-0.10.0rc1-cp36-cp36m-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9cadd6a6edd56df22183f36df316b9c557bbc1823fcf885e1e7a9d573cbf56 |
|
MD5 | a7d182dc55030a21a14fc714fb717ad7 |
|
BLAKE2b-256 | caf4f0072d4811d2c6e3201e367a6a0abc941f34aeaa38e34489e92cbf935ea2 |
Hashes for baize-0.10.0rc1-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d675cf9335b2c3e0a9cb1a397f945e52bbff39583a784b83eabebf0d50b2e88 |
|
MD5 | 757034662d22146bfc0378e70d775edb |
|
BLAKE2b-256 | cbf9b71e29e9873d0d5fc1c7c24a3601b3deae208a8f3bb8583e217cc2d5730c |