Update Flask example file.
@@ -9,6 +9,7 @@ Try the following with httpie (a cURL-like utility, http://httpie.org):
$ http GET :5001/
$ http GET :5001/ name==Ada
$ http POST :5001/add x=40 y=2
+ $ http POST :5001/subtract x=40 y=2
$ http POST :5001/dateadd value=1973-04-10 addend=63
$ http POST :5001/dateadd value=2014-10-23 addend=525600 unit=minutes
"""
@@ -16,7 +17,7 @@ import datetime as dt
from flask import Flask, jsonify
from webargs import fields, validate
-from webargs.flaskparser import use_args, use_kwargs
+from webargs.flaskparser import use_args, use_kwargs, use_kwargs_async
app = Flask(__name__)
@@ -40,6 +41,13 @@ def add(x, y):
return jsonify({"result": x + y})
+@app.route("/subtract", methods=["POST"])
+@use_kwargs_async(add_args)
+async def subtract(x, y):
+ """An async addition endpoint."""
+ return jsonify({"result": x - y})
+
+
dateadd_args = {
"value": fields.Date(required=False),
"addend": fields.Int(required=True, validate=validate.Range(min=1)),
