I am making an extremely simple API using flask-restful and want to process POST-parameters without having to require the users to enter a parameter name, e.g.
curl -d "data" localhost
instead of
curl -d "name=data" localhost
The API is used internally so this usage is not problematic, however, I can't get it to work. If I do
parser.add_argument('', type=str)
then I'm still required to use the equality sign, e.g. -d "=data"
.
parser.add_argumnent(None, type=str)
raises an exception.
Without parser.add_argument()
parser.parse_args()
returns an empty container.
As suggested by @brunsgaard:
Request.form captures all the POST (and PUT) data in a dictionary.
If the input is formed exactly as in the question, the following code grabs it from the dictionary:
request.form.keys()[0]