Update the README
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by digitalxero · committed by digitalxero · parent 3b82b06 · Browse files · 1 file·+52 added−25 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+52 added−25 removed
- other:+52 added−25 removed
Provenance
- Commit
a9e18e9- Tree
b882fd0- Author
digitalxero <none@none>- Committer
digitalxero <none@none>- Parent
3b82b06
1 file changed+52 added−25 removed
modified:README.rst+52 added-25 removed
1 Requests: The Simple (e.g. usable) HTTP Module2 ==============================================3 4-Most existing Python modules for dealing HTTP requests are insane. I have to look up *everything* that I want to do. Most of my worst Python experiences are a result of the various built-in HTTP libraries (yes, even worse than Logging). 4+Most existing Python modules for dealing HTTP requests are insane. I have to look up *everything* that I want to do. Most of my worst Python experiences are a result of the various built-in HTTP libraries (yes, even worse than Logging).5 6 But this one's different. This one's going to be awesome. And simple.7 8-Really simple. 8+Really simple.9 10 Features11 --------12 1 unmodified line14 + Simple HTTP Header Request Attachment15 + Simple Data/Params Request Attachment16 + Simple Multipart File Uploads17 + CookieJar Support18- 18+19 - Simple Basic HTTP Authentication20 + Simple URL + HTTP Auth Registry21 22 6 unmodified lines29 >>> r = requests.get('http://google.com')30 31 32 HTTPS? Basic Authentication? ::33- 33+34 >>> r = requests.get('https://convore.com/api/account/verify.json')35 >>> r.status_code36 40137 38- 38+39 Uh oh, we're not authorized! Let's add authentication. ::40- 41- >>> conv_auth = requests.AuthObject('requeststest', 'requeststest')40+41+ >>> conv_auth = ('requeststest', 'requeststest')42 >>> r = requests.get('https://convore.com/api/account/verify.json', auth=conv_auth)43- 43+44 >>> r.status_code45- 200 46- 45+ 20046+47 >>> r.headers['content-type']48 'application/json'49- 49+50 >>> r.content51 '{"username": "requeststest", "url": "/users/requeststest/", "id": "9408", "img": "censored-long-url"}'52 53 54 55 API56 ---57- 57+58 **Requests:**59 60 All request functions return a Response object (see below).61 62 If a {filename: fileobject} dictionary is passed in (files=...), a multipart_encode upload will be performed.63 If CookieJar object is is passed in (cookies=...), the cookies will be sent with the request.64- 64+65 GET Requests66 >>> request.get(url, params={}, headers={}, cookies=None, auth=None)67 <request object>68- 68+69 HEAD Requests70 >>> request.head(url, params={}, headers={}, cookies=None, auth=None)71 <request object>72- 72+73 PUT Requests74 >>> request.put(url, data='', headers={}, files={}, cookies=None, auth=None)75 <request object>76- 76+77 POST Requests78 >>> request.post(url, data={}, headers={}, files={}, cookies=None, auth=None)79 <request object>80- 80+81 DELETE Requests82 >>> request.delete(url, params={}, headers={}, cookies=None, auth=None)83 <request object>84- 84 85+**AsyncRequests:**86+87+All request functions return a Response object (see below).88+89+If a {filename: fileobject} dictionary is passed in (files=...), a multipart_encode upload will be performed.90+If CookieJar object is is passed in (cookies=...), the cookies will be sent with the request.91+92+ GET Requests93+ >>> request.async.get(url, params={}, headers={}, cookies=None, auth=None)94+ <request object>95+96+ HEAD Requests97+ >>> request.async.head(url, params={}, headers={}, cookies=None, auth=None)98+ <request object>99+100+ PUT Requests101+ >>> request.async.put(url, data='', headers={}, files={}, cookies=None, auth=None)102+ <request object>103+104+ POST Requests105+ >>> request.async.post(url, data={}, headers={}, files={}, cookies=None, auth=None)106+ <request object>107+108+ DELETE Requests109+ >>> request.async.delete(url, params={}, headers={}, cookies=None, auth=None)110+ <request object>111+112+113 **Responses:**87- 114+115 Response.status_code:116 (Integer) Received HTTP Status Code Response117 118 Response.headers:2 unmodified lines121 Response.content:122 (Bytes) Received Content123 124 Response.url98- (String) URL of response. Useful for detecting redirects. 99- 125+ (String) URL of response. Useful for detecting redirects.126+127 Response.ok128 (Bool) True if no errors occurred during the request, and the status_code is kosher.102- 129+130 Response.error131 (HTTPError) If an HTTPError occurred (e.g. status of 404), Otherwise this is None.105- 132+133 Response.raise_for_status()134 Raises HTTPError if a request is not kosher.135 136 10 unmodified lines147 148 To install requests, simply: ::149 150 $ pip install requests124- 151+152 Or, if you absolutely must: ::153 154 $ easy_install requests155 156 But, you really shouldn't do that.130- 157 158 159+160 Contribute161 ----------162 163 If you'd like to contribute, simply fork `the repository`_, commit your changes to the **develop** branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS_.13 unmodified lines