Let's start programming in Python. In this first example, we'll perform a GET request using Python and the requests library:
- Let's open the Atom editor in the Virtual Machine and create a new file by navigating to File | New File.
- We'll import the requests library to start with. This can be done by typing import requests.
- Now, we need to create a variable R, where we'll instantiate a requests object with the GET method, and the target URL in this case is httpbin.org/ip:
import requestsr=requests.get('http://httpbin.org/ip')
- Finally, we print the content of the response using print r.text.
- Save the file in the /Examples/Section-2 folder as Chapter-3.py.
- Let's run it on the Terminal. Open the Terminal and change the directory ...