提交 b89c779d 编写于 作者: AI原吾's avatar AI原吾

+ flask weather api

上级 31e9e9b8
# -*- coding: utf-8 -*-
from flask import Flask, jsonify
from flask_basicauth import BasicAuth
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False # 返回JSON字符串中文修正
app.config['BASIC_AUTH_USERNAME'] = 'admin'
app.config['BASIC_AUTH_PASSWORD'] = '123456'
app.config['BASIC_AUTH_FORCE'] = True # 整个站点都验证
basic_auth = BasicAuth(app)
@app.route('/weather')
def weather():
print({"weather":"晴","temp":25.6,"sensorName":"ENV-002", "sensorType": "out"})
return jsonify({"weather":"晴","temp":25.6,"sensorName":"ENV-002", "sensorType": "out"})
if __name__ == '__main__':
app.run(debug=True)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册