This commit is contained in:
Yûki VACHOT 2021-10-18 08:43:41 +02:00
parent 0f603d3591
commit 816027920e

16
app.py
View file

@ -35,7 +35,7 @@ def searchCity(): # put application's code here
else: else:
search = request.args.get('search') search = request.args.get('search')
if METEOCONCEPT_TOKEN == -1: if METEOCONCEPT_TOKEN is None:
log('Env variable METEOCONCEPT_TOKEN not passed') log('Env variable METEOCONCEPT_TOKEN not passed')
return 'Env variable METEOCONCEPT_TOKEN not passed' return 'Env variable METEOCONCEPT_TOKEN not passed'
else: else:
@ -53,7 +53,7 @@ def getCity(): # put application's code here
else: else:
insee = request.args.get('insee') insee = request.args.get('insee')
if METEOCONCEPT_TOKEN == -1: if METEOCONCEPT_TOKEN is None:
log('Env variable METEOCONCEPT_TOKEN not passed') log('Env variable METEOCONCEPT_TOKEN not passed')
return 'Env variable METEOCONCEPT_TOKEN not passed' return 'Env variable METEOCONCEPT_TOKEN not passed'
else: else:
@ -71,7 +71,7 @@ def ephemeride(): # put application's code here
else: else:
insee = request.args.get('insee') insee = request.args.get('insee')
if METEOCONCEPT_TOKEN == -1: if METEOCONCEPT_TOKEN is None:
log('Env variable METEOCONCEPT_TOKEN not passed') log('Env variable METEOCONCEPT_TOKEN not passed')
return 'Env variable METEOCONCEPT_TOKEN not passed' return 'Env variable METEOCONCEPT_TOKEN not passed'
else: else:
@ -82,7 +82,7 @@ def ephemeride(): # put application's code here
# Information sur les alentours d'une ville # Information sur les alentours d'une ville
@app.route('/around', methods=['POST', 'GET']) @app.route('/around', methods=['POST', 'GET'])
def ephemeride(): # put application's code here def around(): # put application's code here
if request.method == 'POST': if request.method == 'POST':
insee = request.form['insee'] insee = request.form['insee']
radius = request.form['radius'] radius = request.form['radius']
@ -90,7 +90,7 @@ def ephemeride(): # put application's code here
insee = request.args.get('insee') insee = request.args.get('insee')
radius = request.args.get('radius') radius = request.args.get('radius')
if METEOCONCEPT_TOKEN == -1: if METEOCONCEPT_TOKEN is None:
log('Env variable METEOCONCEPT_TOKEN not passed') log('Env variable METEOCONCEPT_TOKEN not passed')
return 'Env variable METEOCONCEPT_TOKEN not passed' return 'Env variable METEOCONCEPT_TOKEN not passed'
else: else:
@ -99,13 +99,9 @@ def ephemeride(): # put application's code here
around = json.loads(f.read()) around = json.loads(f.read())
return json.dumps(around, indent=INDENT, sort_keys=True) return json.dumps(around, indent=INDENT, sort_keys=True)
if __name__ == '__main__': if __name__ == '__main__':
PORT = int(os.environ.get('PORT', 33507)) PORT = int(os.environ.get('PORT', 33507))
# On Linux or MAC 'export METEOCONCEPT_TOKEN=...' (check shell echo $METEOCONCEPT_TOKEN) # On Linux or MAC 'export METEOCONCEPT_TOKEN=...' (check shell echo $METEOCONCEPT_TOKEN)
# On Windows 'set METEOCONCEPT_TOKEN=...' (check on Powershell echo $Env:METEOCONCEPT_TOKEN) # On Windows 'set METEOCONCEPT_TOKEN=...' (check on Powershell echo $Env:METEOCONCEPT_TOKEN)
METEOCONCEPT_TOKEN = int(os.environ.get('METEOCONCEPT_TOKEN', -1)) METEOCONCEPT_TOKEN = os.environ.get('METEOCONCEPT_TOKEN', None)
app.run(host='0.0.0.0', port=PORT, debug=True) app.run(host='0.0.0.0', port=PORT, debug=True)