Added `/json_items`

This commit is contained in:
Felipe M 2020-11-05 10:13:05 +01:00
parent 7efb4d5cde
commit 3894d54a09
1 changed files with 13 additions and 0 deletions

13
app.py
View File

@ -1,3 +1,4 @@
import copy
import json
import logging
import os
@ -237,5 +238,17 @@ def samesite_iframe_view():
return f"iframe on {hostname}"
@app.route("/json_items")
def items_view():
"""
Returns a JSON list with the items specified by the `items_number` parameter.
"""
items_number = request.args.get("items_number", 1)
item = {"this": "is", "a": "json", "big": "body"}
response_body = [copy.copy(item) for i in range(0, int(items_number))]
return jsonify(response_body)
if __name__ == "__main__":
app.run(debug=True, port=8080, host="0.0.0.0")