diff --git a/main.py b/main.py
index 562e349..f4b4e69 100644
--- a/main.py
+++ b/main.py
@@ -1,5 +1,5 @@
import queue
-from flask import Flask, render_template, request, make_response
+from flask import Flask, render_template, request, make_response, flash
from flask_socketio import SocketIO #https://pythonprogramminglanguage.com/python-flask-websocket/
import sqlite3
import time
@@ -37,7 +37,7 @@ def list():
return '
' + text
@app.route("/list/user", methods=['GET'])
-def user():
+def user_info():
username = request.args.get("user")
c.execute("SELECT * FROM users WHERE username = '%s'" % username)
user = c.fetchall()
@@ -89,28 +89,36 @@ def get_addtag_request():
except: #except im Normalen Code!
return "Wrong user id!"
users.put(user_id)
+ print(f"put: {len(users.queue)}")
return render_template("addtag.html", user=user_id)
@socketio.on('addtag')
def request_addtag(data):
global finished
+ print(f"add tag: {len(users.queue)}")
if len(users.queue) > 0:
user = users.queue[len(users.queue) - 1]
if user == data["data"]:
socketio.emit("wait", "wait")
i = 0
while finished != data["data"]:
+ print("waiting")
time.sleep(1)
i += 1
if i > 20:
+ print("timeout")
socketio.emit("error", "timeout")
nothing = users.get()
- pass
- c.execute(f"SELECT * FROM users WHERE id ={user}")
- username = c.fetchall()[0][1]
- c.execute(f"SELECT * FROM tags WHERE userid={user}")
- tag_id = c.fetchall()[0][0]
- socketio.emit("finished", f"Added {tag_id} to {username}")
+ print(f"nothing: {nothing}")
+ print("cleared")
+ break
+ else:
+ finished = None
+ c.execute(f"SELECT * FROM users WHERE id ={user}")
+ username = c.fetchall()[0][1]
+ c.execute(f"SELECT * FROM tags WHERE userid={user}")
+ tag_id = c.fetchall()[0][0]
+ socketio.emit("finished", f"Added {tag_id} to {username}")
else:
socketio.emit("busy", "busy")
else:
@@ -119,7 +127,6 @@ def request_addtag(data):
#api
@app.route("/api/tag_id", methods=['GET'])
def get_id():
- global users
global finished
tag_id = int(request.args.get("id"))
c.execute(f"SELECT * FROM tags WHERE tagid ={tag_id}")
@@ -143,4 +150,3 @@ def get_id():
def main():
atexit.register(exit_handler)
socketio.run(app, host='0.0.0.0', port=5000)
-
diff --git a/templates/addtag.html b/templates/addtag.html
index 96f1224..eba07ec 100644
--- a/templates/addtag.html
+++ b/templates/addtag.html
@@ -12,7 +12,7 @@
socket.emit('addtag', {data: user})
});
socket.on("wait", function(){
- document.write('wait
')
+ document.write('Pleas hold your tag on to the nfc reader
')
});
socket.on("error", function(data) {
alert(data)