Gabe Rainbow
Gabe Rainbow

Reputation: 3738

bottle python put equivalent to post for data

Im using the awesome python bottle app as a JSON server.

POST is working fine but not PUT

I use the following in POST to retrieve the POST'ed data.

data = request.body.getvalue()
if data: 
    ...

Whats the equiv for capturing PUT data?

Secondly, do I use the same --data option on curl for testing (aside from changing the -X verb from POST to PUT

curl -X PUT --data '{"key":"value"}' http://myserver.com/1/object/type

Upvotes: 1

Views: 341

Answers (1)

ron rothman
ron rothman

Reputation: 18128

Whats the equiv for capturing PUT data?

See if this does the trick:

data = request.body.read()

do I use the same --data option on curl for testing

Yep, that should work.

Upvotes: 3

Related Questions