| 12345678910111213141516171819202122232425262728293031323334353637 |
- from flask import Flask, jsonify
- from PN532data import readChip
- import webbrowser
- from threading import Timer
- from flask import render_template
- from flask_cors import CORS
- app = Flask(__name__)
- CORS(app, resources=r'/*')
- @app.route('/readChip')
- def read_chip():
- try:
- result = readChip()
- print(result)
- return jsonify({'code': 200, 'msg': '读取成功',
- 'data': {'list': result[0], 'chipNumber': result[1], 'vaccinationCipher': result[2],
- 'id': result[3]}})
- except Exception as e:
- print(e)
- return jsonify({'code': 500, 'msg': '请见检查芯片是否放好或读卡器连接是否正常'})
- @app.route('/')
- def index():
- return render_template('index.html')
- def open_browser():
- webbrowser.open_new('http://127.0.0.1:9000')
- if __name__ == '__main__':
- # Timer(1, open_browser).start()
- app.run(port=9000, debug=True, host='0.0.0.0')
|