Update
This commit is contained in:
parent
816027920e
commit
82f1bc477f
1 changed files with 14 additions and 0 deletions
14
app.py
14
app.py
|
|
@ -38,6 +38,9 @@ def searchCity(): # put application's code here
|
||||||
if METEOCONCEPT_TOKEN is None:
|
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'
|
||||||
|
elif search is None:
|
||||||
|
log('GET/POST search variable not passed')
|
||||||
|
return 'GET/POST search variable not passed'
|
||||||
else:
|
else:
|
||||||
log('Env variable METEOCONCEPT_TOKEN passed')
|
log('Env variable METEOCONCEPT_TOKEN passed')
|
||||||
with closing(urlopen(API_LOCATION_CITIES + API_TOKEN + METEOCONCEPT_TOKEN + API_SEARCH + search)) as f:
|
with closing(urlopen(API_LOCATION_CITIES + API_TOKEN + METEOCONCEPT_TOKEN + API_SEARCH + search)) as f:
|
||||||
|
|
@ -56,6 +59,9 @@ def getCity(): # put application's code here
|
||||||
if METEOCONCEPT_TOKEN is None:
|
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'
|
||||||
|
elif insee is None:
|
||||||
|
log('GET/POST insee variable not passed')
|
||||||
|
return 'GET/POST insee variable not passed'
|
||||||
else:
|
else:
|
||||||
log('Env variable METEOCONCEPT_TOKEN passed')
|
log('Env variable METEOCONCEPT_TOKEN passed')
|
||||||
with closing(urlopen(API_LOCATION_CITY + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee)) as f:
|
with closing(urlopen(API_LOCATION_CITY + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee)) as f:
|
||||||
|
|
@ -74,12 +80,16 @@ def ephemeride(): # put application's code here
|
||||||
if METEOCONCEPT_TOKEN is None:
|
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'
|
||||||
|
elif insee is None:
|
||||||
|
log('GET/POST insee variable not passed')
|
||||||
|
return 'GET/POST insee variable not passed'
|
||||||
else:
|
else:
|
||||||
log('Env variable METEOCONCEPT_TOKEN passed')
|
log('Env variable METEOCONCEPT_TOKEN passed')
|
||||||
with closing(urlopen(API_EPHEMERIDE + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee)) as f:
|
with closing(urlopen(API_EPHEMERIDE + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee)) as f:
|
||||||
cityEph = json.loads(f.read())
|
cityEph = json.loads(f.read())
|
||||||
return json.dumps(cityEph, indent=INDENT, sort_keys=True)
|
return json.dumps(cityEph, indent=INDENT, sort_keys=True)
|
||||||
|
|
||||||
|
|
||||||
# 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 around(): # put application's code here
|
def around(): # put application's code here
|
||||||
|
|
@ -93,12 +103,16 @@ def around(): # put application's code here
|
||||||
if METEOCONCEPT_TOKEN is None:
|
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'
|
||||||
|
elif insee is None or radius is None:
|
||||||
|
log('GET/POST insee or radius variable not passed')
|
||||||
|
return 'GET/POST insee or radiu variable not passed'
|
||||||
else:
|
else:
|
||||||
log('Env variable METEOCONCEPT_TOKEN passed')
|
log('Env variable METEOCONCEPT_TOKEN passed')
|
||||||
with closing(urlopen(API_OBSERVATIONS_AROUND + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee + API_RADIUS + radius)) as f:
|
with closing(urlopen(API_OBSERVATIONS_AROUND + API_TOKEN + METEOCONCEPT_TOKEN + API_INSEE + insee + API_RADIUS + radius)) as f:
|
||||||
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue