Skip to content
Myr

Added POST to quick start. Modified GET in doc to use httpbin

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Joseph McCullough · committed by Joseph McCullough · parent 8c90c61 · Browse files · 1 file+24 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−2 removed

  • other:+24 added−2 removed

1 file+24 added−2 removed

modified:docs/user/quickstart.rst+24 added-2 removed
23 unmodified lines
24Making a standard request with Requests is very simple.2526Let's get GitHub's public timeline ::2728 r = requests.get('https://github.com/timeline.json')28 r = requests.get("http://httpbin.org/get")2930Now, we have a :class:`Response` object called ``r``. We can get all the31information we need from this.32333435Response Content36----------------3738We can read the content of the server's response::3940 >>> r.content40 '[{"repository":{"open_issues":0,"url":"https://github.com/...41 '{\n "url": "http://httpbin.org/get", \n "headers": ...424344Make a POST Request45------------------4647POST requests are equally simple ::4849 >>> r = requests.post("http://httpbin.org/post")50 5152Suppose you want to send data over HTTP. Simply pass a data53argument to the requests.post method with your dictionary ::5455 >>> dataDict = {"key1":"value1", "key2":"value2"}56 >>> r = requests.post("http://httpbin.org/post", data=dataDict)57 >>> r.content58 '{\n "origin": "::ffff:YourIpAddress", \n "files": {}, \n "form": {\n "key2": "value2", \n "key1": "value1"\n }, 5960Note the data= argument is equivalent to -d in cURL scripts. dataDict will61be form-encoded. 626364Response Status Codes65---------------------6667We can check the response status code::
117 unmodified lines
185186-----------------------187188Ready for more? Check out the :ref:`advanced <advanced>` section.189