Debian Codegraph @

examples/quickstart/put_buffer.py

raw
1 #! /usr/bin/env python
2 # vi:ts=4:et
3
4 import pycurl
5 from io import BytesIO
6
7 c = pycurl.Curl()
8 c.setopt(c.URL, 'https://httpbin.org/put')
9
10 c.setopt(c.UPLOAD, 1)
11 data = '{"json":true}'
12 # READDATA requires an IO-like object; a string is not accepted
13 buffer = BytesIO(data.encode('utf-8'))
14 c.setopt(c.READDATA, buffer)
15
16 c.perform()
17 c.close()