diff --git a/cloud/app.py b/cloud/app.py index afdd73a..f61b0bb 100644 --- a/cloud/app.py +++ b/cloud/app.py @@ -8,6 +8,7 @@ from flask_migrate import Migrate from functools import wraps import jwt +import requests from config import Config @@ -327,5 +328,16 @@ def addPredictedValues(): return str(0) +@app.route('/weather', methods=['POST']) +@token_required +def weather(): + api = app.config['OWM_API_KEY'] + + response = requests.get('http://api.openweathermap.org/data/2.5/weather?q =' + 'modena' + '&appid =' + api) + source = response.content + print(source) + return source + + if __name__ == '__main__': app.run() diff --git a/cloud/config.py b/cloud/config.py index 789eb0c..321e11a 100644 --- a/cloud/config.py +++ b/cloud/config.py @@ -38,3 +38,5 @@ class Config: # JWT TOKEN_SECRET_KEY = environ['SECRET_KEY'] TOKEN_BRIDGE_IDS = environ['BRIDGE_TOKEN_IDs'] + # OpenWeatherMap + OWM_API_KEY = environ['OWM_API_KEY']