From the course: Python Essential Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with responses

Working with responses - Python Tutorial

From the course: Python Essential Libraries

Start my 1-month free trial

Working with responses

- [Instructor] HTTP transactions consist of a request and a response. In the previous example, we saw how to use the Requests library to perform the first part, issuing the request to a server using either Get or Post. In this example, we'll take a look at how to work with the responses that come back from the server. So let's go ahead and open up the responses_start and first, let's take a look at how to handle different status codes that are returned. So I'm going to make a simple request to the HTTP bin testing endpoint that always returns a 200 Code which means that everything worked. So I'll call requests.get and I'll go ahead and access https://bin.org/status and then 200, and then I'll just print out the response which is in the status_code. So let's go ahead and make sure that works by running the code and sure enough, there is the 200 response, right there. However, as I'm sure you all know things don't always…

Contents