https://webargs.readthedocs.io/en/latest/
https://webargs.readthedocs.io/en/latest/quickstart.html#
from flask import Flask from webargs import fields from webargs.flaskparser import use_args
app = Flask(name)
hello_args = {"name": fields.Str(required=True)}
@app.route("/") @use_args(hello_args) def index(args): return "Hello " args["name"]
if name == "main": app.run()
curl http://localhost:5000/?name='World'
Hello World
Webargs will automatically parse:
Query Parameters
$ curl http://localhost:5000/?name='Freddie' Hello Freddie Form Data
$ curl -d 'name=Brian' http://localhost:5000/ Hello Brian JSON Data
$ curl -X POST -H "Content-Type: application/json" -d '{"name":"Roger"}' http://localhost:5000/ Hello Roger