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.

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


@middleware
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 (
    middleware,
    request_response,
    Router,
    Request,
    Response,
    PlainTextResponse,
)


@middleware
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.15.0rc2.tar.gz (38.3 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.15.0rc2-py3-none-any.whl (44.6 kB view details)

Uploaded Python 3

baize-0.15.0rc2-cp310-cp310-win_amd64.whl (313.4 kB view details)

Uploaded CPython 3.10Windows x86-64

baize-0.15.0rc2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (616.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

baize-0.15.0rc2-cp310-cp310-macosx_10_14_x86_64.whl (368.0 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

baize-0.15.0rc2-cp39-cp39-win_amd64.whl (313.3 kB view details)

Uploaded CPython 3.9Windows x86-64

baize-0.15.0rc2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (611.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

baize-0.15.0rc2-cp39-cp39-macosx_10_14_x86_64.whl (367.8 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

baize-0.15.0rc2-cp38-cp38-win_amd64.whl (310.5 kB view details)

Uploaded CPython 3.8Windows x86-64

baize-0.15.0rc2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (606.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

baize-0.15.0rc2-cp38-cp38-macosx_10_14_x86_64.whl (360.0 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

baize-0.15.0rc2-cp37-cp37m-win_amd64.whl (298.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

baize-0.15.0rc2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (455.3 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

baize-0.15.0rc2-cp37-cp37m-macosx_10_14_x86_64.whl (343.8 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

baize-0.15.0rc2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (443.9 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

baize-0.15.0rc2-cp36-cp36m-macosx_10_14_x86_64.whl (336.3 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

Details for the file baize-0.15.0rc2.tar.gz.

File metadata

  • Download URL: baize-0.15.0rc2.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for baize-0.15.0rc2.tar.gz
Algorithm Hash digest
SHA256 3982cda44347c7e8e043bd598989c4cdd391a27ab477272e027cd45f1a130091
MD5 4e21b16504f1a52f236a909a921b5932
BLAKE2b-256 d30195db9eec09d40ccdb3fd19a12da55c1d07999d9ab31282bc6b7a16ff4dfd

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-py3-none-any.whl.

File metadata

  • Download URL: baize-0.15.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 44.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for baize-0.15.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 65fdd28bd5f07e06fdc0dc87f722a4b1363b93b647c1e92e4dd6ea9004110bce
MD5 6d0ca4197503b2a3e5db09bec56d73d8
BLAKE2b-256 6496b34b46010b12b96f2a7844fc8b613b5c444e944abd9757f585131dd24e35

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 313.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for baize-0.15.0rc2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 15fa8d8dc0119de2eb309e5f211ff3fd19b6d172400328d1cd771758ae6b4748
MD5 bc96a0e528492e271ffa1fef1cce7b62
BLAKE2b-256 fd3eca7384b7efc48c9f944b6f7b8d7225608625712d5e5305cd4bbcf2c5558d

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.15.0rc2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d105493397413b723613feedc3228bc9f110944a7ed6b45af5ce15cb58d7da16
MD5 f3e74227152bbad302c7c83d2d001af9
BLAKE2b-256 ed5d6e606f8a5298c4c7d29e7bcaf6fcb5995181045bb7d4f4f885e9f6d41ac7

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp310-cp310-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 368.0 kB
  • Tags: CPython 3.10, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for baize-0.15.0rc2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 6b660f5de91b1a6cc12199b2f9b8c364db45c31e152f616fd75e76dc7029eaf0
MD5 29585b3c834f07433240a113dffefbbe
BLAKE2b-256 450e45dc2fd83f20fbcb584c94ece24f31ec792361842167d1daa671cb3ce5d2

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 313.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for baize-0.15.0rc2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c69badd11ede966fac9605fea5624b90f37044f50d0b64d2283ba03fedb62be2
MD5 436e3f8b13bee9dd6862ba96c896b774
BLAKE2b-256 6d987f767f57aef9c33a89e49953204e8d3bdb43f61132db84357828bc2a9ac5

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.15.0rc2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c1b4a2ef93156bf97e2b311c55ad48e82e354c4280cc4d164665c1553a0bb6b
MD5 4aa0facc453d990f8a5c0927144baf08
BLAKE2b-256 cf9af246f8f800be893f489e12b7b652da8a20041ca5fa00035f643ec8bad0ca

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 367.8 kB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for baize-0.15.0rc2-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 3e86ac938a8c1bb58702c2303d6de0bfccb33906a9b928f0a7d2d7d60630a10d
MD5 e56d34602e8326d4755eeffb029d00a0
BLAKE2b-256 4bbbc6e2a7a8739735b72e1add3d989ea66d21fe2dc293f4cdde89542885e9cf

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 310.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for baize-0.15.0rc2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cbe7b740087aaed8dc58a452761b0c4c36edc4c0430f1ecff6de81fdffd515b4
MD5 78c9dfca108965d2afe912e6da2b5eb0
BLAKE2b-256 a0f5f4ee41252a761e478968885a110ef9a2d2cf67c8dd4127bcfcd542665a23

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.15.0rc2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70054fa3ae1112ea6cca1280e6ba8724ec6eb310f4610d3956fb8875ae4f695d
MD5 d2fd4c6b470590c3aed2be76948e9da2
BLAKE2b-256 35fb9356c8258a32207f2e4351812a96ae3e55a0085faadc141e8c5a4bef8d12

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 360.0 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for baize-0.15.0rc2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 788b462939a17910c73b1fcb29eb1849e8a1b7994ed1af36dd0839db6b8d36ad
MD5 42483d690dd96700dd93fe2309ebc36a
BLAKE2b-256 5c975321b89e6c774074cbfefb35bb816abc2c8b4c5909df751d916cd39e4415

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 298.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for baize-0.15.0rc2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f328a7289a149f4192bfa080bb1023c2a1c48e947f9550b99a07a811cb08db71
MD5 a0819ae4ed4f154a3ae549464bde62ed
BLAKE2b-256 6a24148b82030fb1f3d6129028aada9639fe4d21d915ecbde044d44cd61dcb57

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.15.0rc2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d97096a487ad95f3451efe24dbf63a3981932443b232fd3eaa3f855f1143903
MD5 7d60e0f280d5e90a14791555f6600aef
BLAKE2b-256 ebc95946e4a5c53f8d4f8886f479832453d2ff3c1fdeb4f28399aa27ec2365c6

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 343.8 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for baize-0.15.0rc2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 5ceb03a4093f971d51de5ec13ec5563b091c1ffd4feddc7eb72898e3cdfcb502
MD5 77683708ac6db53b12a57869db632f60
BLAKE2b-256 2d02697c31e7c9e848ca10ccc78dba2fd9aafbce8911c876aff54be360b8ef6a

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for baize-0.15.0rc2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ae02a790490c102e2007f1908b289f332cea22573541a926f823daa4d45969f
MD5 40f50ccc16586d9181962cf364aebe25
BLAKE2b-256 346048312fc06f02a4503f9901a47942a776591650715a74f2d79d09340a575b

See more details on using hashes here.

File details

Details for the file baize-0.15.0rc2-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: baize-0.15.0rc2-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 336.3 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15

File hashes

Hashes for baize-0.15.0rc2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2d5d67f2272558767062ac005d317b6bc703b97b3d56885f5259d31e61eebed2
MD5 5c2a82cc0cebde51976f6e25137a22ab
BLAKE2b-256 1de1326af816813f61442b97fa58f63522f3c2bac26f77f56219ac0a612040f0

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