import threading from flask import Flask, render_template from gevent.pywsgi import WSGIServer from common.read_config import ReadConfig from dao import machinery_dao from device import machinery_service main = Flask(__name__) @main.route('/') def index(): model = "后台数据" return render_template('index.html', model=[model]) @main.route('/load_data', methods=['POST']) def load_data(): show_val = machinery_dao.query_machinery() if len(show_val) == 0: show_val = {} return show_val def startHttp(): serverip = "0.0.0.0" http_port = ReadConfig().get_common_port("http_port") print("启动HTTP:" + serverip + ":" + http_port) WSGIServer((serverip, int(http_port)), main).serve_forever() if __name__ == '__main__': thread_web = threading.Thread(target=machinery_service.lora_db, name='lora_db') thread_web.daemon = True thread_web.start() startHttp()