from flask import Flask,request from utils.DataSearchUtils import MysqlSearchUtils from utils.HttpUtils import HttpUtils from ai_auto_create_creative_job import AiAutoCreateCreativeJob import json from utils import ResultDictUtils from flask_cors import CORS app = Flask(__name__) CORS(app, resources=r'/*') mysql = MysqlSearchUtils() httpUtils = HttpUtils() aiAutoCreateCreativeJob = AiAutoCreateCreativeJob() @app.route('/hello') def hello_word(): print(request.path) print(request.full_path) return 'hello world' @app.route('/getOne') def get_json(): response_dict = {} data = mysql.get_one() response_dict["data"] = data return response_dict @app.route('/getList',methods=["post"]) def get_list(): body = request.json print(body["accountId"]) response_dict = {} list = mysql.get_all() response_dict["list"] = list return response_dict @app.route('/testReport',methods=["get"]) def test_report(): rest = httpUtils.get("http://localhost:8079/getOne",{"accountId":"123"},{"accountId":"123"}) return json.loads(rest) @app.route('/autoCreateCreativeJob') def auto_create_creative_job(): response_dict = ResultDictUtils.common_success_dict account_id = request.args.get("accountId") if 0 == account_id or account_id is None: return ResultDictUtils.params_error_dict rest = aiAutoCreateCreativeJob.auto_create_job(account_id) response_dict["data"] = rest return response_dict if __name__ == '__main__': app.run(host='0.0.0.0',port=8079,debug=True)