Bladeren bron

修改了一些问题

majt 4 jaren geleden
bovenliggende
commit
b909aff095
5 gewijzigde bestanden met toevoegingen van 54 en 19 verwijderingen
  1. 13 5
      PN532data.py
  2. 9 4
      app.py
  3. BIN
      dist/app.exe
  4. 32 0
      myweb.py
  5. 0 10
      templates/index.html

+ 13 - 5
PN532data.py

@@ -135,9 +135,9 @@ def reader():
         raise RuntimeError('设备未连接或标签损坏')
         raise RuntimeError('设备未连接或标签损坏')
     print(list)
     print(list)
     if (len(list) > 0):
     if (len(list) > 0):
-        return list
+        return list, id
     else:
     else:
-        return '0'
+        return '0', '0'
 
 
 
 
 list2 = ['03ff0cfcc10100000cf55402656e7218', 'ee5b49cbcd0e2a707a20c0756263c38f', '99b4df9af78e61cea1a2a3a4a5a6a7a8',
 list2 = ['03ff0cfcc10100000cf55402656e7218', 'ee5b49cbcd0e2a707a20c0756263c38f', '99b4df9af78e61cea1a2a3a4a5a6a7a8',
@@ -206,8 +206,13 @@ list2 = ['03ff0cfcc10100000cf55402656e7218', 'ee5b49cbcd0e2a707a20c0756263c38f',
 
 
 
 
 def readChip():
 def readChip():
-    list = reader()
+    readerData = reader()
+    list = readerData[0]
+    uid = readerData[1]
     list = list2
     list = list2
+    temperature_data = ''
+    chipNumber = ''
+    chipData = ''
     if (list != '0'):
     if (list != '0'):
         chipData = ''.join(list)
         chipData = ''.join(list)
         chipData = chipData[22:]
         chipData = chipData[22:]
@@ -215,5 +220,8 @@ def readChip():
         data = re.findall(r'.{2}', chipData)
         data = re.findall(r'.{2}', chipData)
         jdata = ' 0x'.join(data)
         jdata = ' 0x'.join(data)
         jdata = '0x' + jdata + ' \\n'
         jdata = '0x' + jdata + ' \\n'
-        print(jdata)
-    return decodeData(jdata), chipNumber, chipData
+        temperature_data = decodeData(jdata)
+        temperature_data = ','.join('%s' % id for id in temperature_data)
+        print(temperature_data)
+
+    return temperature_data, chipNumber, chipData, uid

+ 9 - 4
app.py

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

BIN
dist/app.exe


+ 32 - 0
myweb.py

@@ -0,0 +1,32 @@
+from cefpython3 import cefpython as cef
+
+from tkinter import *
+import threading
+import sys
+
+
+# cefpython3 目前只支持python3.7,高版本Python不兼容
+def embed_browser_thread(frame, _rect):
+    sys.excepthook = cef.ExceptHook
+    window_info = cef.WindowInfo(frame.winfo_id())
+    window_info.SetAsChild(frame.winfo_id(), _rect)
+    cef.Initialize()
+    cef.CreateBrowserSync(window_info, url='http://www.baidu.com')
+    cef.MessageLoop()
+
+
+if __name__ == '__main__':
+    root = Tk()
+    root.geometry("800x600")
+
+    frame1 = Frame(root, bg='blue')
+    frame1.pack(side=TOP, fill=X)
+
+    frame2 = Frame(root, bg='white')
+    frame2.pack(side=TOP, fill=X)
+
+    rect = [200, 200, 800, 200]
+    thread = threading.Thread(target=embed_browser_thread, args=(frame1, rect))
+    thread.start()
+
+    root.mainloop()

File diff suppressed because it is too large
+ 0 - 10
templates/index.html


Some files were not shown because too many files changed in this diff