# -*- coding: utf-8 -*- # author:Li Mingjie time:2019/3/7 # Brief: import json from flask import Flask from flask import request from flask_cors import CORS import response_time_analysis import response_error_analysis app = Flask(__name__) CORS(app, supports_credentials=True) @app.route('/SPDAS/response_analysis1', methods=['POST']) def domain(): param = ({"data_type": [{"value": "control"}, {"value": "application"}, {"value": "all"}], "effect_type": [{"value": "cost_time"}, {"value": "response_error"}], "time": "2018-12-01 00:00:00/2018-12-02 00:00:00"}) return json.JSONEncoder().encode(param) @app.route('/SPDAS/response_analysis2', methods=['POST']) def domain_form(): # 需要从request对象读取表单内容: data = request.get_data() json_re = json.loads(data) datatype = json_re['data_type'] effecttype = json_re['effect_type'] m_time = json_re['time'] str_time = str(m_time) m_time = str_time.split('/') starttime = m_time[0] endtime = m_time[1] if effecttype == 'cost_time': image_path = response_time_analysis.cost_time_plot(datatype=datatype, starttime=starttime, endtime=endtime) path = ({"response_image": image_path}) return json.JSONEncoder().encode(path) else: image_path = response_error_analysis.error_data_statistics_plot(datatype=datatype, starttime=starttime, endtime=endtime, graphtype='bar') path = ({"response_image": image_path}) return json.JSONEncoder().encode(path) if __name__ == '__main__': app.run(debug=True, host='10.7.19.129', port=5000)