From 8643c3afa43b2b144c51081f8b2b90a377aa979d Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 10 Jun 2021 00:53:04 -0400 Subject: [PATCH] Inital commit. Basic loop running. Logic to switch check in/out, can scan shelf once to store location. Checking books in currently works. --- main.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..74bdd18 --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +import reprlib + +import requests + +# payload = {'isbn': '9780062113788'} +# r = requests.post('http://library.dandhost.com/lookup', data= {'isbn': '9780062113788'}) +# print(r.text) + +URL = 'http://library.dandhost.com' + +UserID = 1 +Card = 1 +Shelf = 1 +Mode = 1 + + +def processBook(ISBN): + if Mode == 1: + r = requests.post(URL+'/checkin/', data={'isbn': ISBN, 'locationid': Shelf, 'userid': UserID}) + print(r.text) + + +while True: + var = str(input()) + x = var.split('.') + if x[0] == 'LOC': + Shelf = x[1] + print('Switching shelf to shelf #' + Shelf) + elif x[0] == 'CI': + Mode = 1 + elif x[0] == 'CO': + Mode = 2 + elif x[0] == 'CARD': + Card = 1 + else: + ISBN = x[0] + print(ISBN) + processBook(ISBN) +