Flask + Schema = Cazart!
Project description
cazart
Flask + schema = cazart!
cazart is a small helper for writing schematized JSON endpoints with Flask. It rolls
schema into Flask's route
decorator, allowing
for one-shot route and schema specification.
Installation
cazart requires Python 3.6 or newer.
pip3 install cazart
Usage
To use cazart, just swap your Flask
instance out for a Cazart
one:
from cazart import Cazart
app = Cazart(__name__)
You can access all of Flask's baseline functionality (including non-validated routes)
via app.flask
.
Then, use app.route
to specify a combination route and schema:
from cazart import Cazart
from schema import Schema, Or
app = Cazart(__name__)
@app.route("/cazart", schema=Schema({"name": Or("alice", "bob", "mary")}))
def cazart(res):
print(f"my verified payload is {res}!")
return ("ok", 200)
See the examples for full usage examples, including custom error handling and dispatching to different schemas on a route based on HTTP method.
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
File details
Details for the file cazart-0.0.4.tar.gz
.
File metadata
- Download URL: cazart-0.0.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff77899c712898aa5fb16ea8e84f595769c883a04d09313a681f5b122cf4474b |
|
MD5 | 6721449130dd336804608a93778c738a |
|
BLAKE2b-256 | f5339fd4cc89372c91991f9c3be3e489a4ca8a8d8af390280d4f5be75f23550d |