From 695ad587c1d6ac93426aac5274e6bc79b3ba1df0 Mon Sep 17 00:00:00 2001 From: Bruno Rocha Date: Fri, 18 May 2018 14:59:39 -0300 Subject: [PATCH] Added /json endpoint to match the /xml one --- httpbin/core.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/httpbin/core.py b/httpbin/core.py index 5e4bd6a..e430e86 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -1472,6 +1472,35 @@ def xml(): return response +@app.route("/json") +def a_json_endpoint(): + """Returns a simple JSON document. + --- + tags: + - Response formats + responses: + 200: + description: An JSON document. + """ + return flask_jsonify( + slideshow={ + 'title': 'Sample Slide Show', + 'date': 'date of publication', + 'author': 'Yours Truly', + 'slides': [ + {'type': 'all', + 'title': 'Wake up to WonderWidgets!'}, + {'type': 'all', + 'title': 'Overview', + 'items': [ + 'Why WonderWidgets are great', + 'Who buys WonderWidgets' + ]} + ] + } + ) + + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("--port", type=int, default=5000)