Update
This commit is contained in:
parent
1fe1c08bbd
commit
ce6ffcf1c9
1 changed files with 18 additions and 8 deletions
14
app.py
14
app.py
|
|
@ -7,16 +7,26 @@ from urllib.request import urlopen
|
||||||
import json
|
import json
|
||||||
from config import *
|
from config import *
|
||||||
|
|
||||||
|
|
||||||
|
# logging helper
|
||||||
|
def log(*args):
|
||||||
|
print(args[0] % (len(args) > 1 and args[1:] or []))
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/config')
|
@app.route('/config')
|
||||||
def config(): # put application's code here
|
def config(): # put application's code here
|
||||||
return str(INDENT) + str(WEATHER) + str(WINDDIRS)
|
return str(INDENT) + str(WEATHER) + str(WINDDIRS)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello_world(): # put application's code here
|
def hello_world(): # put application's code here
|
||||||
return 'Hello World!'
|
return 'Hello World!'
|
||||||
|
|
||||||
|
|
||||||
# TODO Recherche d'une ville
|
# TODO Recherche d'une ville
|
||||||
@app.route('/searchCity', methods=['POST', 'GET'])
|
@app.route('/searchCity', methods=['POST', 'GET'])
|
||||||
def searchCity(): # put application's code here
|
def searchCity(): # put application's code here
|
||||||
|
|
@ -39,8 +49,8 @@ if __name__ == '__main__':
|
||||||
# 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 = int(os.environ.get('METEOCONCEPT_TOKEN', -1))
|
||||||
if METEOCONCEPT_TOKEN == -1:
|
if METEOCONCEPT_TOKEN == -1:
|
||||||
print('Env variable METEOCONCEPT_TOKEN not passed')
|
log('Env variable METEOCONCEPT_TOKEN not passed')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print('Env variable METEOCONCEPT_TOKEN passed')
|
log('Env variable METEOCONCEPT_TOKEN passed')
|
||||||
app.run(host='0.0.0.0', port=PORT, debug=True)
|
app.run(host='0.0.0.0', port=PORT, debug=True)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue