commit
This commit is contained in:
60
simulator.py
Normal file
60
simulator.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# simulator.py
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
SERVER = "https://5000--main--orange-crane-13--harry-esses.coder.harryesses.com/scan"
|
||||||
|
|
||||||
|
print("RFID Scan Simulator")
|
||||||
|
print("Type 'exit' to quit")
|
||||||
|
print()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
uid = input("UID: ").strip()
|
||||||
|
|
||||||
|
if uid.lower() == "exit":
|
||||||
|
break
|
||||||
|
|
||||||
|
location = input(
|
||||||
|
"Location ID: "
|
||||||
|
).strip()
|
||||||
|
|
||||||
|
action = input(
|
||||||
|
"Action (blank/bathroom): "
|
||||||
|
).strip()
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"uid": uid,
|
||||||
|
"location_id": location,
|
||||||
|
"action": action
|
||||||
|
}
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("Sending Scan:")
|
||||||
|
print(payload)
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
response = requests.post(
|
||||||
|
SERVER,
|
||||||
|
json=payload,
|
||||||
|
timeout=5
|
||||||
|
)
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(
|
||||||
|
f"Status: {response.status_code}"
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
print(response.json())
|
||||||
|
except:
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print()
|
||||||
|
print(f"Error: {e}")
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("-" * 40)
|
||||||
|
print()
|
||||||
Reference in New Issue
Block a user