Status codes
What if we wanted to know whether anything unexpected had happened to our request? Or what if we wanted to know whether our response contained any data before we read the data out? Maybe we're expecting a large response, and we want to quickly see if our request has been successful without reading the whole response.
HTTP responses provide a means for us to do this through status codes. We can read the status code of a response by using its status attribute.
>>> response.status 200
Status codes are integers that tell us how the request went. The 200 code informs us that everything went fine.
There are a number of codes, and each one conveys a different meaning. According to their first digit, status codes are classified into the following ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access