Created
February 19, 2020 15:03
-
-
Save a-recknagel/cd8d91bd967a5b95f56d1c7bfc1aa79a to your computer and use it in GitHub Desktop.
honestly who still uses xml as data protocol?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, jsonify | |
app = Flask(__name__) | |
@app.route("/", methods=['POST']) | |
def foo(): | |
return jsonify([*request.form.keys()]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 & 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