Skip to content

Instantly share code, notes, and snippets.

@a-recknagel
Created February 19, 2020 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-recknagel/cd8d91bd967a5b95f56d1c7bfc1aa79a to your computer and use it in GitHub Desktop.
Save a-recknagel/cd8d91bd967a5b95f56d1c7bfc1aa79a to your computer and use it in GitHub Desktop.
honestly who still uses xml as data protocol?
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/", methods=['POST'])
def foo():
return jsonify([*request.form.keys()])
# have flask installed
$ FLASK_APP=app.py
$ flask run &
$ curl -X POST -H 'application/xml; charset=utf-8' -d 'foo=<data content="bar">' http://127.0.0.1:5000/
["foo"]
# good so far
$ curl -X POST -H 'application/xml; charset=utf-8' -d 'foo=<data content="bar & baz">' http://127.0.0.1:5000/
["foo"," baz\">"]
# as expected...
$ curl -X POST -H 'application/xml; charset=utf-8' -d 'foo=<data content="bar &amp; baz">' http://127.0.0.1:5000/
["foo","amp; baz\">"]
# ._.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment