def get(self): """Called when a GET request is made to /nabaztag/api/location :returns: An HTTP response. An attempt is made to obtain the Nabaztag's physical location from an instance of the GeoLocate class. If successful, the location is returned as JSON, if not, an error is returned. """ locator = GeoLocate(INTERFACE) try: location = locator.get_location() return location, 200 except LocationError: return {"status": 503, "message": "Location service temporarily unavailable"}, 503
def get(self): """Called when a GET request is made to /nabaztag/api/weather :returns: An HTTP response. An attempt is made to obtain the weather for the Nabaztag's location from an instance of the Weather class. If successful, the weather is returned as JSON, if not (due to either the location or weather APIs being unavailable), an error is returned. """ locator = GeoLocate(INTERFACE) try: location = locator.get_location() weather = Weather(location) return weather.get_weather(), 200 except LocationError: return {"status": 503, "message": "Could not determine location. Weather service temporarily unavailable."}, 503 except WeatherError: return {"status": 503, "message": "Weather service temporarily unavailable."}, 503