I saw on this thread on StackOverflow: How to find location with IP address in Python?
The answer worked for me, but so far I have only tested it on localhost, and I want to make sure, that the IP-address is actually the IP from the user, and not the server itself.
The reason I'm in doubt because I tried to different methods to test this out
#I'm using a Mail API, but here I will print for simplicity
'IP-address from user ' + request.remote_addr #retures 127.0.0.1 when running on localhost
whenever I try with the ipinfo API, I get the actual IP-address from my internet connection, not from localhost.
url= 'http://ipinfo.io/json'
response = urlopen(url)
data = json.load(response)
IP=data['ip']
org=data['org']
city = data['city']
country=data['country']
region=data['region']
print('IP : {4} \nRegion : {1} \nCountry : {2} \nCity : {3} \nOrg : {0}'.format(org,region,country,city,IP))
#returns actual IP-address from my internet connection
How can I ensure, that the later solution actual returns the IP and location from the user, the accesses the service