60 lines
996 B
Python
60 lines
996 B
Python
# 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() |