Skip to content

Commit

Permalink
Added language parameter in geolocator api so that we always get engl…
Browse files Browse the repository at this point in the history
…ish response
  • Loading branch information
prachi-77 committed Oct 12, 2024
1 parent 5067e33 commit a80a7ed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions helpers/get_current_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import requests
# from serpapi.serp_api_client import SerpApiClientException, SerpApiQuotaExceeded


def get_country_name(country_code):
try:
country = pycountry.countries.get(alpha_2=country_code)
Expand All @@ -29,14 +28,16 @@ def get_current_coord():
return None



def reverse_geocode(lat, lon):
url = "https://nominatim.openstreetmap.org/reverse"
params = {
'format': 'json',
'lat': lat,
'lon': lon,
'zoom': 18,
'addressdetails': 1
'addressdetails': 1,
'accept-language': 'en'
}

headers = {
Expand Down Expand Up @@ -152,10 +153,9 @@ def read_txt():


def get_user_location_details(lat,long):
location = get_current_coord()
print("user loc is--",location)
location_info = {}
location_results = reverse_geocode(lat,long)
print("location results are",location_results)
if location_results is not None:
location_info['location'] = location_results
currency = get_currency(location_info['location']['country'])[0]
Expand All @@ -165,3 +165,4 @@ def get_user_location_details(lat,long):
else:
print("Unable to retrieve your GPS coordinates.")


0 comments on commit a80a7ed

Please sign in to comment.