-import sys
-
-baseurl = 'http://api.openweathermap.org/data/2.5/weather'
-debug = False
-
-def getweather(apikey, cityid):
- query = baseurl + '?units=metric&APPID={}&id={}&lang=de'.format(apikey, cityid)
- try:
- response = requests.get(query)
- if response.status_code != 200:
- response = 'N/A'
- return response
- else:
- weatherdata = response.json()
- return weatherdata
- except requests.exceptions.RequestException as error:
- print (error)
- sys.exit(1)