Tampa
Tampa

Reputation: 78254

Python and bottle - how to get post data of a protocol bufer

I need to parse a protocol buffer send via a post using bottle.

How do I get PB to parse?

I tried the following but did nt work:

@post('/test')
def test():
    br = test_pb2.MyRequest()
    br.ParseFromString(request.files.data)

Upvotes: 3

Views: 1487

Answers (1)

defnull
defnull

Reputation: 4199

The raw body data is available through request.body, a file-like object (either a real file or a BytesIO depending on its size). request.body.read() should do the job for you.

Upvotes: 5

Related Questions