fake_ckan.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from flask import Flask, request, jsonify
  2. app = Flask(__name__)
  3. request_store = []
  4. @app.route("/api/action/task_status_update_many", methods=['GET', 'POST'])
  5. def task_status_update_many():
  6. request_store.append({
  7. "data": request.json,
  8. "headers": dict(request.headers)
  9. })
  10. return 'ok'
  11. @app.route("/api/action/task_status_update", methods=['GET', 'POST'])
  12. def task_status_update():
  13. request_store.append({
  14. "data": request.json,
  15. "headers": dict(request.headers)
  16. })
  17. return 'ok'
  18. @app.route("/api/action/task_status_show", methods=['GET', 'POST'])
  19. def task_status_show():
  20. request_store.append({
  21. "data": request.json,
  22. "headers": dict(request.headers)
  23. })
  24. return jsonify({'success': True,
  25. 'result': {'value': '', 'error': '', 'stack': ''}})
  26. @app.route("/api/action/resource_update", methods=['GET', 'POST'])
  27. def resource_update():
  28. request_store.append({
  29. "data": request.json,
  30. "headers": dict(request.headers)
  31. })
  32. return 'ok'
  33. @app.route("/last_request", methods=['GET', 'POST'])
  34. def last_request():
  35. return jsonify(request_store.pop())
  36. @app.route("/", methods=['GET', 'POST'])
  37. def ok():
  38. return 'ok'
  39. if __name__ == "__main__":
  40. app.run(port=50001)