Код: Выделить всё
import threading
def checkValidQRCode(qrcode):
url=''
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json" # Specify the content type as JSON
}
response = requests.get(url, headers=headers)
# Check the response status code
if response.status_code == 200:
# Parse the JSON response
json = response.json()
print(json)
if len(json)>0:
print("unlock door from check valid qr code")
if(json[0]["Static"]==False): #non static code, should mark as spent
#run update access code on separate thread
thread = threading.Thread(target=updateAccessCodeToSpent, args=(json[0]["Id"]))
thread.start()
return "unlock"
def updateAccessCodeToSpent(id):
time.sleep(5)
while(True):
if someCondition == True:
checkValidQRCode("qrcode")
print("this is code right after checkValidQRCode() in the loop")
Подробнее здесь: https://stackoverflow.com/questions/789 ... -in-python