post request

This commit is contained in:
bton 2024-02-16 21:16:05 +01:00
parent c1834c3a76
commit 944e3c1628

View file

@ -1,5 +1,9 @@
import time import time
import nfc import nfc
import subprocess
import requests
url="http://172.16.1.105/api/"
def get_reader(): def get_reader():
devices = subprocess.check_output("lsusb") devices = subprocess.check_output("lsusb")
@ -13,7 +17,15 @@ def get_reader():
def onTagSense(tag): def onTagSense(tag):
id = int.from_bytes(tag.identifier, "big") id = int.from_bytes(tag.identifier, "big")
print(id) 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 return True
except:
None
return False
def start_nfc_normal(): def start_nfc_normal():
device = get_reader() device = get_reader()