#!/usr/bin/python3 from requests import get,post url = "http://api.openweathermap.org/data/2.5/weather?id=2845222&APPID=a9a65433e56edeee32db51a8f283a03f&units=metric" try: resp = get(url) data = resp.json() except: print("URL load failed") raise SystemExit(2) temp = float(data["main"]["temp"]) #pres = float(data["main"]["pressure"]) #humi = float(data["main"]["humidity"]) try: post("http://localhost/middleware/data/70919b00-c5f8-11ea-8152-ed29ae9e5e38.json", data={"value" : temp }) #post("http://localhost/middleware/data/.json", data={"value" : pres }) #post("http://localhost/middleware/data/.json", data={"value" : humi }) except: print("Couldn't post to VZ Middleware.") raise SystemExit(3)