server.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from flask import Flask,request
  2. from utils.DataSearchUtils import MysqlSearchUtils
  3. from utils.HttpUtils import HttpUtils
  4. from ai_auto_create_creative_job import AiAutoCreateCreativeJob
  5. import json
  6. from utils import ResultDictUtils
  7. app = Flask(__name__)
  8. mysql = MysqlSearchUtils()
  9. httpUtils = HttpUtils()
  10. aiAutoCreateCreativeJob = AiAutoCreateCreativeJob()
  11. @app.route('/hello')
  12. def hello_word():
  13. print(request.path)
  14. print(request.full_path)
  15. return 'hello world'
  16. @app.route('/getOne')
  17. def get_json():
  18. response_dict = {}
  19. data = mysql.get_one()
  20. response_dict["data"] = data
  21. return response_dict
  22. @app.route('/getList')
  23. def get_list():
  24. response_dict = {}
  25. list = mysql.get_all()
  26. response_dict["list"] = list
  27. return response_dict
  28. @app.route('/testReport',methods=["get"])
  29. def test_report():
  30. rest = httpUtils.get("http://localhost:8079/getOne",{"accountId":"123"},{"accountId":"123"})
  31. return json.loads(rest)
  32. @app.route('/autoCreateCreativeJob')
  33. def auto_create_creative_job():
  34. response_dict = ResultDictUtils.common_success_dict
  35. account_id = request.args.get("accountId")
  36. if 0 == account_id or account_id is None:
  37. return ResultDictUtils.params_error_dict
  38. rest = aiAutoCreateCreativeJob.auto_create_job(account_id)
  39. response_dict["data"] = rest
  40. return response_dict
  41. if __name__ == '__main__':
  42. app.run(host='0.0.0.0',port=8079,debug=True)