You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
622 B

  1. from flask import Flask, request
  2. from flask_restful import Resource, Api, abort
  3. import json
  4. import os
  5. app = Flask(__name__)
  6. api = Api(app)
  7. db_path = os.path.join(app.root_path, 'databases', 'users.json')
  8. with open(db_path, 'r') as f:
  9. users = json.load(f)
  10. class Alert(Resource):
  11. def post(self):
  12. args = request.form
  13. username= ""
  14. for user in users:
  15. if users[user]["id"] == args["id"]:
  16. username=user
  17. break
  18. trust = int(users[username]["trustability"])
  19. if trust > 20 or args["accepted"] == "true":
  20. return {"success":True}
  21. else:
  22. return {"success":False,"penalty":"{}".format(100*(20-trust))}