Files
libraryClient/main.py

40 lines
777 B
Python

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)