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. 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.

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.23.1.tar.gz (60.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

baize-0.23.1-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

baize-0.23.1-cp313-cp313-win_amd64.whl (267.8 kB view details)

Uploaded CPython 3.13Windows x86-64

baize-0.23.1-cp313-cp313-manylinux_2_39_x86_64.whl (605.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

baize-0.23.1-cp313-cp313-macosx_15_0_arm64.whl (571.5 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

baize-0.23.1-cp312-cp312-win_amd64.whl (267.5 kB view details)

Uploaded CPython 3.12Windows x86-64

baize-0.23.1-cp312-cp312-manylinux_2_39_x86_64.whl (607.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

baize-0.23.1-cp312-cp312-macosx_15_0_arm64.whl (572.6 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

baize-0.23.1-cp311-cp311-win_amd64.whl (265.9 kB view details)

Uploaded CPython 3.11Windows x86-64

baize-0.23.1-cp311-cp311-manylinux_2_39_x86_64.whl (591.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

baize-0.23.1-cp311-cp311-macosx_15_0_arm64.whl (566.2 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

baize-0.23.1-cp310-cp310-win_amd64.whl (266.6 kB view details)

Uploaded CPython 3.10Windows x86-64

baize-0.23.1-cp310-cp310-manylinux_2_39_x86_64.whl (599.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

baize-0.23.1-cp310-cp310-macosx_13_0_x86_64.whl (324.4 kB view details)

Uploaded CPython 3.10macOS 13.0+ x86-64

baize-0.23.1-cp39-cp39-win_amd64.whl (266.5 kB view details)

Uploaded CPython 3.9Windows x86-64

baize-0.23.1-cp39-cp39-manylinux_2_39_x86_64.whl (597.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

baize-0.23.1-cp39-cp39-macosx_13_0_x86_64.whl (324.0 kB view details)

Uploaded CPython 3.9macOS 13.0+ x86-64

File details

Details for the file baize-0.23.1.tar.gz.

File metadata

  • Download URL: baize-0.23.1.tar.gz
  • Upload date:
  • Size: 60.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for baize-0.23.1.tar.gz
Algorithm Hash digest
SHA256 98346866e4420d21036b0435fae2be6fb01a0cf32b3c8a5398cdb545fea3e022
MD5 e87b3fa72a9c465902d98d2d3a36acea
BLAKE2b-256 cb324aa56759a5ab980551f89f077791d122670fe387c8480b701e7048e59521

See more details on using hashes here.

File details

Details for the file baize-0.23.1-py3-none-any.whl.

File metadata

  • Download URL: baize-0.23.1-py3-none-any.whl
  • Upload date:
  • Size: 52.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for baize-0.23.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b68a6822899d78ecfd8a501e12bbe5eb2ead1aa32f1cf079ca3c0c928cbf87b9
MD5 fc7abab4b0910d8c5265ac39a5292e6d
BLAKE2b-256 70eedf058475964ce06bb7110669a8b9d3626b426049cedf701c47aab297bed7

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: baize-0.23.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 267.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for baize-0.23.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4cc930282e6e432b0ac5a291c9374976c2d1f4248da51b14d0d4f7ba844a33a6
MD5 0077c1aba8ee5aa817af50b70acafdfb
BLAKE2b-256 221c9bafa83f6c62eefe04ec94256520bf91b2a45104a4af8fb5e75232e313fb

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 447769a49c38b23605a234bb99a12eddc096b77c1cb827727d265ac6b751b2e3
MD5 0a1f8eea052818a62e4e4cf2acd01988
BLAKE2b-256 10dd3b155eb2ace44347f51e9c34fe3bafb22cb85d35a7a27510e869bf7b4932

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4047c4fa6b3092f985f4777d9da09e31ad576b98b177a88138ad539deaca4fbc
MD5 cbe10d42eedfb20be2179d8bef5ca9ba
BLAKE2b-256 7871d5c33d11ce7ad1f65de63c82f1d35cd9b7997f2506390b2dbbfb74fff981

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: baize-0.23.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 267.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for baize-0.23.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 19bd3f3209012e1e1154c71eed140dc5fb35aa579afda55d5cd10aecd0f51f15
MD5 1a2c0828f9e8ba734fc8355780f7e2c7
BLAKE2b-256 fc6393f2c542280201c5d686792fa805767bfd8a9969138ce4a1e143659f7a66

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 7ddab634331ebb6dba41526541ec2a727f5b31befea7e3344176ce639c7ca0bb
MD5 dcac7b9daa518d06ae5bac6818abb571
BLAKE2b-256 fbc11a1785fcfad242117acb2cf1592dad3bac627820e734f6c62f2a29aef6ee

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 447e50f9f4e722536e0d9fb09dc50c9f9b6b2ef675cbf8d0883e71177770983e
MD5 ace04ced214f8354130b6f79455a3fce
BLAKE2b-256 1fdbac983917edb926c2d4108e414f52ea869b0db9a3b561980a76334be87f3d

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: baize-0.23.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 265.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for baize-0.23.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f0ab063550ced9003c77a1019cf73e92984978cd47e3125d5aefb5bfb3b5dccf
MD5 f81fc554dfa7cbc171199c60e5494634
BLAKE2b-256 da624f39948a3b51cc0baa694c207c8c62acc6b718b251d6717a6f5b7ce07ddd

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 1774edf024371b6b329ccc8ef745a8c72b3b25b1e6613f2f54194cffe22b675c
MD5 3eff866b0da39de2ce98f53cbbdae8bf
BLAKE2b-256 f9bb316ec251cadf0312f9412697c207f05aaff696e7d0aaddc5912162b4dbe3

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 26dce1a6207b0ba9b0181ef86462263de2531fe4d4938bc214b82ea60fe918ce
MD5 53f882324f60b82aecab2c1c6f27c7f6
BLAKE2b-256 642a6d1e87609a152475e9da951a0aabcd91fcbbc723bcd1900083400a071a13

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: baize-0.23.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 266.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for baize-0.23.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 17b6df3e2d3ea1d2800b3e3fa1e5f88a115f9b2f1c4c6aacf07595f9af57f321
MD5 548a25789230cd15c65f25cbc884025f
BLAKE2b-256 7a15f9ef2368f28f9f29f48bced9462eef7dd822d5881006dd6cc296b55f4a87

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 a5d2b3466157cee65fe639b6f1cf0ca0719a3429d9535d6939c44afbfd687a67
MD5 d10530ab62c6a196b0206b5c16462ea2
BLAKE2b-256 10b24c5fe4e45d5f2cc4fc009f72fbb9b7157f37421e739044670c7693f3b32c

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 4ae72a1c94bef336f1f7741ba24c5286673b92e522247b45de60f63fd1210a46
MD5 209734a94f3f1ed479841c3b64f8ce44
BLAKE2b-256 2a64e139a65a5c20f3dce4a98f122f5aaa3a767a0c0c51ecce792f4fb3925796

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: baize-0.23.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 266.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for baize-0.23.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f984048a7aa4fab303db5117ff2ddeab2867e1a80a461a0796013ff1aa11b96a
MD5 5230a36c963a2b8e9a658aaa1437e87b
BLAKE2b-256 d21df9806dae561829dd991bddce992f04942afb0792cf20b72594db8e01b2e0

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d0012c3671d349db287893d3e3b02de874f3a74f0f8820c9688c8818369802c4
MD5 4dec4d0bc46c80283bba76aa36df2f04
BLAKE2b-256 9a75b965690732432e12e4857b0968cabcb2f3c20046ccb87f9f058607196771

See more details on using hashes here.

File details

Details for the file baize-0.23.1-cp39-cp39-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.23.1-cp39-cp39-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 0000baf7a147035b86335bf6fcbc54836159907f70d5cebe1f597669e4bb85aa
MD5 77cf8ba600fdd201279d65dda252e97b
BLAKE2b-256 470fbf0908280fe33d8f70d13f21d92479ff06b7f8b83b19c48d725fc2df08f5

See more details on using hashes here.

Supported by

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