From 4d6e8c931c9ffdac137539b945d09fad384f5757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C3=BBki=20Vachot?= Date: Mon, 18 Oct 2021 08:41:15 +0200 Subject: [PATCH] Update --- app.py | 18 ++++++++++++++++++ config.py | 1 + 2 files changed, 19 insertions(+) diff --git a/app.py b/app.py index 84319a8..290d453 100644 --- a/app.py +++ b/app.py @@ -80,6 +80,24 @@ def ephemeride(): # put application's code here cityEph = json.loads(f.read()) return json.dumps(cityEph, indent=INDENT, sort_keys=True) +# TODO Information sur la ville et Ephéméride +@app.route('/around', methods=['POST', 'GET']) +def ephemeride(): # put application's code here + if request.method == 'POST': + insee = request.form['insee'] + radius = request.form['radius'] + else: + insee = request.args.get('insee') + radius = request.args.get('radius') + + if METEOCONCEPT_TOKEN == -1: + log('Env variable METEOCONCEPT_TOKEN not passed') + return 'Env variable METEOCONCEPT_TOKEN not passed' + else: + log('Env variable METEOCONCEPT_TOKEN passed') + with closing(urlopen(API_OBSERVATIONS_AROUND + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee + API_RADIUS + radius)) as f: + around = json.loads(f.read()) + return json.dumps(around, indent=INDENT, sort_keys=True) # TODO Information sur les alentours d'une ville diff --git a/config.py b/config.py index adcfa1a..f24521d 100644 --- a/config.py +++ b/config.py @@ -7,6 +7,7 @@ BASE_API_URL = 'https://api.meteo-concept.com/api/' API_TOKEN = '?token=' API_SEARCH = '&search=' API_INSEE = '&insee=' +API_RADIUS = '&radius=' API_LOCATION_CITIES = BASE_API_URL + 'location/cities' API_LOCATION_CITY = BASE_API_URL + 'location/city'