Skip to main content

BáiZé

Codecov PyPI - Python Version

Powerful and exquisite WSGI/ASGI framework/toolkit. Only relies on the standard library.

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

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.

import time
from typing import Callable
from baize.wsgi import (
    decorator,
    request_response,
    Router,
    Request,
    Response,
    PlainTextResponse,
)


@decorator
def timer(request: Request, next_call: Callable[[Request], Response]) -> Response:
    start_time = time.time()
    response = next_call(request)
    end_time = time.time()
    response.headers["x-time"] = str(round((end_time - start_time) * 1000))
    return response


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


@request_response
@timer
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.

import time
from typing import Awaitable, Callable
from baize.asgi import (
    decorator,
    request_response,
    Router,
    Request,
    Response,
    PlainTextResponse,
)


@decorator
async def timer(
    request: Request, next_call: Callable[[Request], Awaitable[Response]]
) -> Response:
    start_time = time.time()
    response = await next_call(request)
    end_time = time.time()
    response.headers["x-time"] = str(round((end_time - start_time) * 1000))
    return response


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


@request_response
@timer
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.

Metadata

Release files for baize 0.23.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baize 0.23.1
File Size Uploaded
baize-0.23.1.tar.gz 60.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for baize 0.23.1
File
baize-0.23.1-py3-none-any.whl Python 3 none any Details
baize-0.23.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
baize-0.23.1-cp313-cp313-manylinux_2_39_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.39+ x86-64 Details
baize-0.23.1-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
baize-0.23.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
baize-0.23.1-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details
baize-0.23.1-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
baize-0.23.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
baize-0.23.1-cp311-cp311-manylinux_2_39_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.39+ x86-64 Details
baize-0.23.1-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
baize-0.23.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
baize-0.23.1-cp310-cp310-manylinux_2_39_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.39+ x86-64 Details
baize-0.23.1-cp310-cp310-macosx_13_0_x86_64.whl CPython 3.10 CPython 3.10 macOS 13.0+ x86-64 Details
baize-0.23.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
baize-0.23.1-cp39-cp39-manylinux_2_39_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.39+ x86-64 Details
baize-0.23.1-cp39-cp39-macosx_13_0_x86_64.whl CPython 3.9 CPython 3.9 macOS 13.0+ x86-64 Details

Total release size: 6.8 MB

Release files / baize-0.23.1.tar.gz

Download URL baize-0.23.1.tar.gz
Size 60.6 kB
Tags Source
SHA-256 checksum
How to use checksums
98346866e4420d21036b0435fae2be6fb01a0cf32b3c8a5398cdb545fea3e022
BLAKE2b-256 checksum
How to use checksums
cb324aa56759a5ab980551f89f077791d122670fe387c8480b701e7048e59521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / baize-0.23.1-py3-none-any.whl

Download URL baize-0.23.1-py3-none-any.whl
Size 52.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b68a6822899d78ecfd8a501e12bbe5eb2ead1aa32f1cf079ca3c0c928cbf87b9
BLAKE2b-256 checksum
How to use checksums
70eedf058475964ce06bb7110669a8b9d3626b426049cedf701c47aab297bed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / baize-0.23.1-cp313-cp313-win_amd64.whl

Download URL baize-0.23.1-cp313-cp313-win_amd64.whl
Size 267.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
4cc930282e6e432b0ac5a291c9374976c2d1f4248da51b14d0d4f7ba844a33a6
BLAKE2b-256 checksum
How to use checksums
221c9bafa83f6c62eefe04ec94256520bf91b2a45104a4af8fb5e75232e313fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / baize-0.23.1-cp313-cp313-manylinux_2_39_x86_64.whl

Download URL baize-0.23.1-cp313-cp313-manylinux_2_39_x86_64.whl
Size 605.0 kB
Tags CPython 3.13 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
447769a49c38b23605a234bb99a12eddc096b77c1cb827727d265ac6b751b2e3
BLAKE2b-256 checksum
How to use checksums
10dd3b155eb2ace44347f51e9c34fe3bafb22cb85d35a7a27510e869bf7b4932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / baize-0.23.1-cp313-cp313-macosx_15_0_arm64.whl

Download URL baize-0.23.1-cp313-cp313-macosx_15_0_arm64.whl
Size 571.5 kB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
4047c4fa6b3092f985f4777d9da09e31ad576b98b177a88138ad539deaca4fbc
BLAKE2b-256 checksum
How to use checksums
7871d5c33d11ce7ad1f65de63c82f1d35cd9b7997f2506390b2dbbfb74fff981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release files / baize-0.23.1-cp312-cp312-win_amd64.whl

Download URL baize-0.23.1-cp312-cp312-win_amd64.whl
Size 267.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
19bd3f3209012e1e1154c71eed140dc5fb35aa579afda55d5cd10aecd0f51f15
BLAKE2b-256 checksum
How to use checksums
fc6393f2c542280201c5d686792fa805767bfd8a9969138ce4a1e143659f7a66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / baize-0.23.1-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL baize-0.23.1-cp312-cp312-manylinux_2_39_x86_64.whl
Size 607.7 kB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
7ddab634331ebb6dba41526541ec2a727f5b31befea7e3344176ce639c7ca0bb
BLAKE2b-256 checksum
How to use checksums
fbc11a1785fcfad242117acb2cf1592dad3bac627820e734f6c62f2a29aef6ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / baize-0.23.1-cp312-cp312-macosx_15_0_arm64.whl

Download URL baize-0.23.1-cp312-cp312-macosx_15_0_arm64.whl
Size 572.6 kB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
447e50f9f4e722536e0d9fb09dc50c9f9b6b2ef675cbf8d0883e71177770983e
BLAKE2b-256 checksum
How to use checksums
1fdbac983917edb926c2d4108e414f52ea869b0db9a3b561980a76334be87f3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / baize-0.23.1-cp311-cp311-win_amd64.whl

Download URL baize-0.23.1-cp311-cp311-win_amd64.whl
Size 265.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
f0ab063550ced9003c77a1019cf73e92984978cd47e3125d5aefb5bfb3b5dccf
BLAKE2b-256 checksum
How to use checksums
da624f39948a3b51cc0baa694c207c8c62acc6b718b251d6717a6f5b7ce07ddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / baize-0.23.1-cp311-cp311-manylinux_2_39_x86_64.whl

Download URL baize-0.23.1-cp311-cp311-manylinux_2_39_x86_64.whl
Size 591.0 kB
Tags CPython 3.11 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
1774edf024371b6b329ccc8ef745a8c72b3b25b1e6613f2f54194cffe22b675c
BLAKE2b-256 checksum
How to use checksums
f9bb316ec251cadf0312f9412697c207f05aaff696e7d0aaddc5912162b4dbe3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / baize-0.23.1-cp311-cp311-macosx_15_0_arm64.whl

Download URL baize-0.23.1-cp311-cp311-macosx_15_0_arm64.whl
Size 566.2 kB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
26dce1a6207b0ba9b0181ef86462263de2531fe4d4938bc214b82ea60fe918ce
BLAKE2b-256 checksum
How to use checksums
642a6d1e87609a152475e9da951a0aabcd91fcbbc723bcd1900083400a071a13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / baize-0.23.1-cp310-cp310-win_amd64.whl

Download URL baize-0.23.1-cp310-cp310-win_amd64.whl
Size 266.6 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
17b6df3e2d3ea1d2800b3e3fa1e5f88a115f9b2f1c4c6aacf07595f9af57f321
BLAKE2b-256 checksum
How to use checksums
7a15f9ef2368f28f9f29f48bced9462eef7dd822d5881006dd6cc296b55f4a87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / baize-0.23.1-cp310-cp310-manylinux_2_39_x86_64.whl

Download URL baize-0.23.1-cp310-cp310-manylinux_2_39_x86_64.whl
Size 599.4 kB
Tags CPython 3.10 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
a5d2b3466157cee65fe639b6f1cf0ca0719a3429d9535d6939c44afbfd687a67
BLAKE2b-256 checksum
How to use checksums
10b24c5fe4e45d5f2cc4fc009f72fbb9b7157f37421e739044670c7693f3b32c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / baize-0.23.1-cp310-cp310-macosx_13_0_x86_64.whl

Download URL baize-0.23.1-cp310-cp310-macosx_13_0_x86_64.whl
Size 324.4 kB
Tags CPython 3.10 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
4ae72a1c94bef336f1f7741ba24c5286673b92e522247b45de60f63fd1210a46
BLAKE2b-256 checksum
How to use checksums
2a64e139a65a5c20f3dce4a98f122f5aaa3a767a0c0c51ecce792f4fb3925796
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / baize-0.23.1-cp39-cp39-win_amd64.whl

Download URL baize-0.23.1-cp39-cp39-win_amd64.whl
Size 266.5 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
f984048a7aa4fab303db5117ff2ddeab2867e1a80a461a0796013ff1aa11b96a
BLAKE2b-256 checksum
How to use checksums
d21df9806dae561829dd991bddce992f04942afb0792cf20b72594db8e01b2e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / baize-0.23.1-cp39-cp39-manylinux_2_39_x86_64.whl

Download URL baize-0.23.1-cp39-cp39-manylinux_2_39_x86_64.whl
Size 597.4 kB
Tags CPython 3.9 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
d0012c3671d349db287893d3e3b02de874f3a74f0f8820c9688c8818369802c4
BLAKE2b-256 checksum
How to use checksums
9a75b965690732432e12e4857b0968cabcb2f3c20046ccb87f9f058607196771
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / baize-0.23.1-cp39-cp39-macosx_13_0_x86_64.whl

Download URL baize-0.23.1-cp39-cp39-macosx_13_0_x86_64.whl
Size 324.0 kB
Tags CPython 3.9 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
0000baf7a147035b86335bf6fcbc54836159907f70d5cebe1f597669e4bb85aa
BLAKE2b-256 checksum
How to use checksums
470fbf0908280fe33d8f70d13f21d92479ff06b7f8b83b19c48d725fc2df08f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.23.1 This release

17 release files

0.19.0

2 release files

0.18.0

3 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page