This week's goal was to handle default country code that would be used to
format the phone number and display more details about it. I came up with 3
alternatives to resolve this
- Using a configuration file within the package
- Declaring an environment variable DEBDIALER_COUNTRY
- Using the user's IP address
    - I thought I had managed to extract the user's inet address from eth
or wlo using netifaces but that wasn't my public IP. I'm now going to curl
to checkip.dyndns.org at the beginning of my program to fetch the IP address
    - I'm using this module to fetch the user's country code
https://pythonhosted.org/python-geoip/. There were a problems involved in
installing this but it eventually worked it.
   - Another solution that single handedly resolves both tasks involve
sending sending a request to ipinfo.io. Though the response takes some time
but it returns the country as well.

Cheers,
Vishal Gupta
‌

Reply via email to