Learning Python Network Programming
APIs in Action S3 buckets and objects S3 organizes the data that we store in it using two concepts: buckets and objects. An obje ...
Chapter 3 First we'll set up our command line interpreter and initialize the authentication. Create a file called s3_client.py a ...
APIs in Action Next, we create our auth object. We'll use this in conjunction with Requests to add AWS authentication to our API ...
Chapter 3 location.text = auth.region data = ET.tostring(XML, encoding='utf-8') xml_pprint(data) Here we create an XML tree foll ...
APIs in Action Now run the client, and if everything works as expected, then we will get a confirmation message. Make sure that ...
Chapter 3 Note that we open the local file in binary mode. The file could contain any type of data, so we don't want text transf ...
APIs in Action We have now included a header in our HTTP request, x-amz-acl, which specifies a permission set to be applied to t ...
Chapter 3 r = requests.put(url, data=data, headers=headers, auth=auth) if r.ok: print('Uploaded {} OK'.format(local_path)) else: ...
APIs in Action Parsing XML and handling errors If you ran into any errors while running the aforementioned code, then you'll not ...
Chapter 3 First we need to open an interactive Python shell, and then generate the aforementioned error message again by using t ...
APIs in Action Here, we have used the findall() method of the root element. This method will provide us with a list of all the d ...
Chapter 3 We could improve a few other things, especially if we are going to make this into a production application. The comman ...
APIs in Action This creates the bucket in the default standard US region. We can supply a different region, as shown here: fr ...
Chapter 3 Downloading also follows a similar pattern. Try the following commands: bucket = conn.get_bucket('mybucket.example. ...
APIs in Action Encoding and decoding We use the json module for working with JSON in Python. Let's create a JSON representation ...
Chapter 3 Also, it is useful to know how JSON handles nested objects. d = { ... 'Chapman': ['King Arthur', 'Brian'], ... ' ...
APIs in Action JSON doesn't have a tuple data type, so the json module will cast it to a list. If we convert it back: j = jso ...
Chapter 3 A Twitter world clock To illustrate some of the functionalities of the Twitter API, we're going to write the code for ...
APIs in Action Authenticating requests We now have enough information for authenticating requests. Twitter uses an authenticatio ...
Chapter 3 if __name__ == '__main__': auth_obj = init_auth() Remember that consumer_secret and access_secret act as the password ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf