Skip to main content

Flask-Caster: Cast Types of Flask Query Parameters

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

✨🍰✨

Release files for Flask-Caster 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Caster 0.1.0
File Size Uploaded
Flask-Caster-0.1.0.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-Caster 0.1.0
File Interpreter ABI Platform
Flask_Caster-0.1.0-py2-none-any.whl Python 2 none any Details

Total release size: 6.9 kB

Release files / Flask-Caster-0.1.0.tar.gz

Download URL Flask-Caster-0.1.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
64fc9afd7bb7e46df5811e6d5e24379dc6449b92ad855da1c1a7892504d84f96
BLAKE2b-256 checksum
How to use checksums
b369a7129ccd1408d1f063e7547de1f978ea98f2745c57421b1f69f2ead83453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / Flask_Caster-0.1.0-py2-none-any.whl

Download URL Flask_Caster-0.1.0-py2-none-any.whl
Size 4.3 kB
Tags Python 2
SHA-256 checksum
How to use checksums
9383a79eb4510722db7b2f294c9eb5adf23cf0d6a6a0a8899468eef55a69e897
BLAKE2b-256 checksum
How to use checksums
f899f5a4145858f389d7875304e8eba5350f1b3dab63667eb7c2ddcbf04fbfa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page