LiveWebHook.py 1003 B

1234567891011121314151617181920212223242526272829303132333435
  1. import datetime
  2. import logging
  3. import traceback
  4. import requests
  5. from flask import json # To read json data
  6. from flask import request # To receive headers
  7. from flask import Flask # To be able to start the application
  8. from Apietl.constant.ConfConstant import ConfConstant
  9. from Apietl.bytedance_etl.report.AdvertiserReport import AdvertiserReport
  10. from Apietl.ruixuan.report.LiveAccountReport import LiveAccountReport
  11. app = Flask(__name__)
  12. @app.route('/')
  13. def api_root():
  14. return 'Welcome guys'
  15. @app.route('/webhook/live_account_report', methods=['POST'])
  16. def api_webhook_messages():
  17. print(json.loads(request.data))
  18. my_info = json.loads(request.data)
  19. account_id = my_info["account_id"]
  20. start_date = my_info["start_date"]
  21. end_date = my_info["end_date"]
  22. date_type = my_info["date_type"]
  23. LiveAccountReport().handler(date_type, account_id, start_date, end_date)
  24. return '200'
  25. if __name__ == '__main__':
  26. app.run(port=3456, host=ConfConstant.LiveURL, debug=True)