webHook.py 859 B

1234567891011121314151617181920212223242526272829303132
  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 ConfConstant import ConfConstant
  9. from report.AccountReport import AccountReport
  10. app = Flask(__name__)
  11. @app.route('/')
  12. def api_root():
  13. return 'Welcome guys'
  14. @app.route('/webhook/account_report', methods=['POST'])
  15. def api_webhook_messages():
  16. print(json.loads(request.data))
  17. my_info = json.loads(request.data)
  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)