Skip to main content
import json

from flask import Flask, jsonify

from flask_args import args


app = Flask(__name__)
app.debug = True


@app.route('/foo', methods=['POST'])
@args('form', bar=int)
@args('args', baz=float, spam=str)
def foo(bar, baz, spam):
return jsonify({'bar': bar, 'baz': baz, 'spam': spam})


@app.route('/echo', methods=['GET', 'POST'])
@args('values', msg=str)
def echo(msg):
return msg

if __name__ == '__main__':
with app.test_client() as client:
r = client.post('/foo?baz=3.14&spam=spam', data={'bar': 2718281828})
assert json.loads(r.data) == {
'baz': 3.14, 'bar': 2718281828, 'spam': 'spam'}

r = client.get('/echo?msg=hello')
assert r.data == 'hello'

r = client.post('/echo', data={'msg': 'hello'})
assert r.data == 'hello'

Release files for flask-args 0.3.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-args 0.3.0
File Size Uploaded
flask-args-0.3.0.zip 3.1 kB Details

Release files / flask-args-0.3.0.zip

Download URL flask-args-0.3.0.zip
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f8feb6dfbea3b9f84c20f20b82609ea55971e619fdd876c5c39ab5e159c0300a
BLAKE2b-256 checksum
How to use checksums
1d5cd9f85d7dd387a5c6989306986d5e243f919aa157e454da9fef2e56a6ecb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.0

1 release file

0.1.0

1 release file

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