diff --git a/weather/weather_apis.py b/weather/weather_apis.py index 9e85442..a70b6a1 100644 --- a/weather/weather_apis.py +++ b/weather/weather_apis.py @@ -13,8 +13,13 @@ # You will need to use these functions, but you don't need to edit this file. import geocoder +from geocoder.osm import OsmQuery import requests +class OsmQueryWithHeaders(OsmQuery): + def _build_headers(self, provider_key, **kwargs): + return {"User-Agent": "Making With Code CS Curriculum"} + def geocode_location(location_string): """Translates a location string into latitude and longitude coordinates. Uses the OpenStreetMap API. Returns a dict with keys 'lat' and 'lng' @@ -23,7 +28,7 @@ def geocode_location(location_string): >>> geocode_location('11 Wall Street, New York') {"lat": -74.010865, "lng": 40.7071407} """ - result = geocoder.osm(location_string) + result = OsmQueryWithHeaders(location_string) if result: lat, lng = result.latlng return {'lat': lat, 'lng': lng}