demo_year_limit.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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, request, 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. if request.method == 'POST':
  18. post_form = request.form
  19. print("/al/cus/yearLimit POST请求参数post_form:{}".format(str(post_form)))
  20. if request.method == 'GET':
  21. args_form = request.args
  22. print("/al/cus/yearLimit GET请求参数args_form:{}".format(str(args_form)))
  23. result = {
  24. "code": "0",
  25. "msg": "跨境额度查询成功",
  26. "data": {
  27. "rows": [
  28. {
  29. "serviceTime": "1576555391775",
  30. "result": {
  31. "totalAmount": 1474.00,
  32. "innerbalance": 24526.00
  33. },
  34. "success": "true",
  35. "message": ""
  36. }
  37. ]
  38. }
  39. }
  40. content = json.dumps(result)
  41. print("模拟额度返回数据:{}".format(content))
  42. return content
  43. if __name__ == '__main__':
  44. app.run(
  45. host='127.0.0.1',
  46. port=2001,
  47. debug=True
  48. )