From 944e3c16289722c4e860c3c8a7f886e1afd6a261 Mon Sep 17 00:00:00 2001 From: bton Date: Fri, 16 Feb 2024 21:16:05 +0100 Subject: [PATCH] post request --- NFC_Reader.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/NFC_Reader.py b/NFC_Reader.py index 6e61275..308495b 100644 --- a/NFC_Reader.py +++ b/NFC_Reader.py @@ -1,5 +1,9 @@ import time import nfc +import subprocess +import requests + +url="http://172.16.1.105/api/" def get_reader(): devices = subprocess.check_output("lsusb") @@ -11,9 +15,17 @@ def get_reader(): raise Exception("\n\n Error: NFC reader not found") def onTagSense(tag): - id = int.from_bytes(tag.identifier, "big") - print(id) - return True + id = int.from_bytes(tag.identifier, "big") + print(id) + print(f"{url}tag_id") + response = requests.post(f"{url}tag_id", data={"id":id}) + print(response.json()) + try: + if response.json()["mode"] == "balance": + return True + except: + None + return False def start_nfc_normal(): device = get_reader()