From 64d10cba0e8c0ffe3b16b29c93f736efbb366e6e Mon Sep 17 00:00:00 2001 From: John Sheehan Date: Wed, 12 Mar 2014 14:53:46 -0700 Subject: [PATCH] Add xml endpoint --- httpbin/core.py | 8 +++++++- httpbin/templates/sample.xml | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 httpbin/templates/sample.xml diff --git a/httpbin/core.py b/httpbin/core.py index 602378f..29760a7 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -45,7 +45,6 @@ tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') app = Flask(__name__, template_folder=tmpl_dir) - # ----------- # Middlewares # ----------- @@ -535,5 +534,12 @@ def image(): return status_code(404) +@app.route("/xml") +def xml(): + response = make_response(render_template("sample.xml")) + response.headers["Content-Type"] = "application/xml" + return response + + if __name__ == '__main__': app.run() diff --git a/httpbin/templates/sample.xml b/httpbin/templates/sample.xml new file mode 100644 index 0000000..5ff0957 --- /dev/null +++ b/httpbin/templates/sample.xml @@ -0,0 +1,24 @@ + + + + + + + + + Wake up to WonderWidgets! + + + + + Overview + Why WonderWidgets are great + + Who buys WonderWidgets + + +