twisted / treq

Python requests like API built on top of Twisted's HTTP client.
Other
587 stars 140 forks source link

Homepage POST example should use json shorthand #278

Closed twm closed 4 years ago

twm commented 4 years ago

The current example could use the json shorthand:

def main(reactor, *args):
    d = treq.post('https://httpbin.org/post',
                  json.dumps({"msg": "Hello!"}).encode('ascii'),
                  headers={b'Content-Type': [b'application/json']})
    d.addCallback(print_response)
    return d

We should certainly have an example of data, but putting this particular example on the homepage implies that json doesn't exist.