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'

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-args-0.3.0.zip (3.1 kB view details)

Uploaded Source

File details

Details for the file flask-args-0.3.0.zip.

File metadata

  • Download URL: flask-args-0.3.0.zip
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for flask-args-0.3.0.zip
Algorithm Hash digest
SHA256 f8feb6dfbea3b9f84c20f20b82609ea55971e619fdd876c5c39ab5e159c0300a
MD5 c01b36378dbee8d7664213b66b78d469
BLAKE2b-256 1d5cd9f85d7dd387a5c6989306986d5e243f919aa157e454da9fef2e56a6ecb5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 file

0.2.0

1 file

0.1.0

1 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