July 2019
Beginner to intermediate
302 pages
9h 38m
English
In Python 3, mock has been included as a standard package in the unittest library.
For the purpose of this recipe, first, we need to install the geoip2 library and the corresponding database:
$ pip3 install geoip2
You also need to download the free geoip database from the MaxMind website to a location of your preference and then unzip the file. For the sake of simplicity, I have downloaded it to the project folder itself:
$ wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz$ tar -xvzf GeoLite2-City.tar.gz
After completing the preceding steps, you should have a folder with the prefix Geolite2-City-. This folder contains the geoip database with the .mmdb extension that we will use ahead in this recipe. ...