Inital commit. Basic loop running. Logic to switch check in/out, can scan shelf once to store location. Checking books in currently works.

This commit is contained in:
dan
2021-06-10 00:53:04 -04:00
commit 8643c3afa4

39
main.py Normal file
View File

@@ -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)