Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,10 +32,21 @@ art_styles = [x.strip() for x in open('art_styles.txt').readlines()]
|
|
32 |
font_path = hf_hub_download("jonathang/fonts-ttf", "Vogue.ttf")
|
33 |
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
@cachetools.cached(cache={})
|
36 |
def get_lat_long(zip):
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
class Chat:
|
|
|
32 |
font_path = hf_hub_download("jonathang/fonts-ttf", "Vogue.ttf")
|
33 |
|
34 |
|
35 |
+
@cachetools.cached(cache={})
|
36 |
+
def get_lat_long_gmaps(zip):
|
37 |
+
api_key = os.environ["GMAPS_API"]
|
38 |
+
url = f"https://maps.googleapis.com/maps/api/geocode/json?address={zip}&key={api_key}"
|
39 |
+
resp = requests.get(url).json()
|
40 |
+
latlng = resp['results'][0]['geometry']['location']
|
41 |
+
return latlng['lat'], latlng['lng']
|
42 |
+
|
43 |
@cachetools.cached(cache={})
|
44 |
def get_lat_long(zip):
|
45 |
+
try:
|
46 |
+
loc = geopy.Nominatim(user_agent='weatherboy-gpt').geocode(str(zip))
|
47 |
+
return loc.latitude, loc.longitude
|
48 |
+
except:
|
49 |
+
return get_lat_long_gmaps(zip)
|
50 |
|
51 |
|
52 |
class Chat:
|