Skip to main content

Flask + Schema = Cazart!

Project description

cazart

Build Status

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

cazart-0.0.2.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file cazart-0.0.2.tar.gz.

File metadata

  • Download URL: cazart-0.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for cazart-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c69ca931f101e68fc35379717289d24a166b57acfbbc421f5c73d476c5062633
MD5 2ab24cce0eb70a5e19fec13ec1d1ddbf
BLAKE2b-256 95a0c03baf86b959de6f278fe584870b7fa74330b9da88b1b88f49b538856bd5

See more details on using hashes here.

Supported by

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