demo_year_limit.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/python
  2. # -*- coding: UTF-8 -*-
  3. #
  4. # 模拟远端额度查询API
  5. # author: Scott Chen
  6. # date: 2019-12-18
  7. import json
  8. from flask import Flask, Response
  9. # Flask对象
  10. app = Flask(__name__)
  11. def response_headers(content):
  12. resp = Response(content)
  13. resp.headers['Access-Control-Allow-Origin'] = '*'
  14. return resp
  15. @app.route('/al/cus/yearLimit', methods=['GET', 'POST'])
  16. def query_year_limit():
  17. result = {
  18. "code": "0",
  19. "msg": "跨境额度查询成功",
  20. "data": {
  21. "rows": [
  22. {
  23. "serviceTime": "1576555391775",
  24. "result": {
  25. "totalAmount": 1474.00,
  26. "innerbalance": 24526.00
  27. },
  28. "success": "true",
  29. "message": ""
  30. }
  31. ]
  32. }
  33. }
  34. content = json.dumps(result)
  35. print("模拟额度返回数据:{}".format(content))
  36. return content
  37. if __name__ == '__main__':
  38. app.run(
  39. host='127.0.0.1',
  40. port=2001,
  41. debug=True
  42. )