from gevent import monkey; monkey.patch_all() from flask import Flask, request, jsonify from gevent.pywsgi import WSGIServer import config from log_config import LogConfig from dim_classify import * app = Flask(__name__) # hnsw模型数据检索 @app.route('/dim_classify', methods=['GET', 'POST']) def retrieve(): if request.method == 'POST': # 获取post数据 retrieve_dict = request.get_json() # 接收日志采集 dc_logger.info(config.log_msg.format(id="多维分类", type="dim_classify接收", message=retrieve_dict)) sentence = retrieve_dict["sentence"] questype = retrieve_dict["quesType"] # 多维分类 res_list = dim_classify(sentence, questype) # 返回日志采集 dc_logger.info(config.log_msg.format(id="多维分类", type="dim_classify返回", message=res_list)) return jsonify(res_list) if __name__ == '__main__': # 日志采集初始化 dc_LogConfig = LogConfig(config.retrieval_path, "dim_classify") dc_logger = dc_LogConfig.get_log() # 多维分类模型初始化 dim_classify = Dimension_Classification() # app.run(host='0.0.0.0',port='8837') server = WSGIServer(('0.0.0.0', 8837), app) server.serve_forever()