from flask import Flask from flask import render_template, redirect, request from flask_restful import Resource, Api import requests import pickle
app = Flask(name) api = Api(app)
class HelloWorld(Resource): def post(self): r = requests.get('https://samples.openweathermap.org/data/2.5/weather?zip=16802,us&appid=157d320b7d029e653c67902f982784ff')
json_object_r = r.json()
temp_k = float(json_object_r['main']['temp'])
temp_c = temp_k - 273.15
tempp_c = int(temp_c)
pickle_in = open("var.pickle", "wb")
tempp_c = pickle.load(pickle_in)
# pressure
p = requests.get('https://samples.openweathermap.org/data/2.5/weather?zip=16802,us&appid=157d320b7d029e653c67902f982784ff')
json_object_p = p.json()
press_k = float(json_object_p['main']['pressure'])
# wind
# speed
w = requests.get('https://samples.openweathermap.org/data/2.5/weather?zip=16802,us&appid=157d320b7d029e653c67902f982784ff')
json_object_w = w.json()
wind_k = float(json_object_w['wind']['speed'])
# gust
g = requests.get('https://samples.openweathermap.org/data/2.5/weather?zip=16802,us&appid=157d320b7d029e653c67902f982784ff')
json_object_g = g.json()
gust_g = float(json_object_g['wind']['gust'])
return {tempp_c}
api.add_resource(HelloWorld, '/')
if name == 'main': app.run(debug=True)
return json.dumps(tempp_c)
. If it's not json serialisable - consider some binary format - you can even send a pickled object back - if the endpoint is meant for applications. – avloss