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.

45 lines
939 B

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. from flask import Flask, jsonify, request, abort,Response
  2. from multiprocessing import Process
  3. import requests
  4. import reader
  5. import json
  6. import urllib3
  7. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  8. app = Flask(__name__)
  9. user = {}
  10. class Reader():
  11. def __init__(self):
  12. read = reader.Read(self)
  13. p1 = Process(target=read.detect)
  14. p1.start()
  15. def received(self, data):
  16. r = requests.get('https://0.0.0.0:5000/users/{}'.format(data), verify=False)
  17. requests.get('http://0.0.0.0:3000/set', data={'data': r.text})
  18. qr_reader = Reader()
  19. @app.route('/set')
  20. def set_data():
  21. global user
  22. user = json.loads(request.form['data'])
  23. resp = Response("OK")
  24. resp.headers['Access-Control-Allow-Origin'] = '*'
  25. return resp
  26. @app.route('/get')
  27. def get_qr():
  28. if user == {}:
  29. abort(404)
  30. resp = Response(json.dumps(user))
  31. resp.headers['Access-Control-Allow-Origin'] = '*'
  32. return resp
  33. app.run(host='0.0.0.0', port=3000)