flaskBack.py 827 B

1234567891011121314151617181920212223242526272829
  1. from flask import Flask, request
  2. from interface import annotate
  3. from flask_cors import CORS
  4. from flask import jsonify
  5. from utils.fileio import load_json
  6. app = Flask("PrivacyScan")
  7. cors = CORS(app, resources={r"/scan": {"origins": "*"}})
  8. @app.route("/scan", methods=['POST'])
  9. def scan():
  10. print(request.get_json())
  11. source = request.get_json()['source']
  12. entire = request.get_json()['entire']
  13. data_type = request.get_json()['dataType']
  14. purpose_dict = request.get_json()['purpose']
  15. data_type = load_json(data_type)
  16. purpose_dict = load_json(purpose_dict)
  17. lattice = {'dataType': data_type, 'purpose': purpose_dict}
  18. result = annotate(source, lattice,
  19. entire)
  20. print(source)
  21. return jsonify(result)
  22. if __name__ == '__main__':
  23. app.run(host="0.0.0.0",post=5000,debug=True)