Making REST requests with urllib
A web application has two essential parts:
- A client: This can be a user's browser, but may also be a mobile device app. In some cases, a web server may be a client of other web servers.
- A server: This provides the web services and resources we've been looking at, in the Using the Flask framework for RESTful APIs, and Parsing the query string in a request recipes, as well as other recipes, such as Parsing a JSON request and Implementing authentication for web services.
A browser-based client will generally be written in JavaScript. Mobile apps are written in a variety of languages, with a focus on Java or Kotlin for Android devices and Objective-C with Swift for iOS devices.
There are several user stories that involve RESTful API clients written in Python. How can we create a Python program that is a client of RESTful web services?
Getting ready
We'll assume that we have a web server based on the...