41 lines
903 B
Python
41 lines
903 B
Python
from flask import Flask
|
|
from utils import query_weather
|
|
from utils.log import Log
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route('/weather', methods=['GET'])
|
|
def weather():
|
|
log = Log().getlog()
|
|
response = query_weather.query_weather()
|
|
log.info(response)
|
|
|
|
return response, 200
|
|
|
|
|
|
@app.route('/weather_all', methods=['GET'])
|
|
def weather_all():
|
|
log = Log().getlog()
|
|
response = query_weather.query_weather(extensions='all')
|
|
log.info(response)
|
|
|
|
return response, 200
|
|
|
|
|
|
@app.route('/weather_flag', methods=['GET'])
|
|
def weather_flag():
|
|
log = Log().getlog()
|
|
response = query_weather.query_weather()
|
|
log.info(response)
|
|
weather = response['lives'][0]['weather']
|
|
# weather包含雨字符串
|
|
if '雨' in weather:
|
|
return {"weather":1}, 200
|
|
else:
|
|
return {"weather":0}, 200
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=1314, debug=False)
|