webHook.py 864 B

123456789101112131415161718192021222324252627282930313233
  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 rocketmq.client import Producer, Message
  9. from ConfConstant import ConfConstant
  10. from report.AccountReport import AccountReport
  11. app = Flask(__name__)
  12. @app.route('/')
  13. def api_root():
  14. return 'Welcome guys'
  15. @app.route('/webhook/account', methods=['POST'])
  16. def api_webhook_messages():
  17. my_info = json.loads(request.param)
  18. account_id = my_info["account_id"]
  19. start_date = my_info["start_time"]
  20. end_date = my_info["end_time"]
  21. date_type = my_info["date_type"]
  22. AccountReport().handler(date_type, account_id, start_date, end_date)
  23. if __name__ == '__main__':
  24. app.run(port=8765, host=ConfConstant.URL, debug=True)