Skip to main content

A simple Flask extension for automatically casting the type of query arguments.

Project description

This simple Flask extension allows you to cast the type of (and assign defaults to) request query parameters in Flask.

Example Usage

from flask import Flask
from flask_caster import FlaskCaster

app = Flask(__name__)

caster = FlaskCaster(app)
caster.ints = ['size']
caster.booleans = ['json']
caster.always = ['json']

This will do a few things:

  • Assure that the size query parameter is always an integer.

  • Assure that the json query parameter is always an boolean.

  • Assure that the json query parameter is always present, even if if it wasn’t provided by the end-user.

Assignable properties include ints, booleans, always, and always_default. The always_default property can be set to any value, or to a callable, which will receive one keyword argument: arg_name.

For boolean casting, 0, false, f, and null will automatically be converted to False.

Installation

$ pip install Flask-Caster

✨🍰✨

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

Flask-Caster-0.1.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

Flask_Caster-0.1.0-py2-none-any.whl (4.3 kB view details)

Uploaded Python 2

File details

Details for the file Flask-Caster-0.1.0.tar.gz.

File metadata

File hashes

Hashes for Flask-Caster-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64fc9afd7bb7e46df5811e6d5e24379dc6449b92ad855da1c1a7892504d84f96
MD5 c7ade9146d718d913855547438065226
BLAKE2b-256 b369a7129ccd1408d1f063e7547de1f978ea98f2745c57421b1f69f2ead83453

See more details on using hashes here.

File details

Details for the file Flask_Caster-0.1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for Flask_Caster-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 9383a79eb4510722db7b2f294c9eb5adf23cf0d6a6a0a8899468eef55a69e897
MD5 6ddedfc2fcd0889e4d98c174d29dbabc
BLAKE2b-256 f899f5a4145858f389d7875304e8eba5350f1b3dab63667eb7c2ddcbf04fbfa4

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