I want to check the user's geolocation like the country code, and this is my code:
from urllib.request import urlopen
url = 'http://ipinfo.io/json'
response = urlopen(url)
data = json.load(response)
country = data['country']
print(country)
when I run it in my local machine, it shows my current location, but when I run this script in my ec2 server, it shows the region of the ec2 itself.
how can I get the actual user's location, not the ec2 region?
Updated and Solution
Thanks to Mousetail, i need to use IP in the URL:
https://ipinfo.io/[the ip of the user]/json