diff --git a/index.html b/index.html
index 4448632..701f64e 100644
--- a/index.html
+++ b/index.html
@@ -7,6 +7,9 @@
+
+
diff --git a/main.py b/main.py
index ed303c0..0468504 100644
--- a/main.py
+++ b/main.py
@@ -21,12 +21,22 @@ class Book(Base):
__tablename__ = 'Book'
id = Column(Integer, primary_key=True, autoincrement=True)
userid = Column(Integer)
+ locationid = Column(Integer)
Title = Column(TEXT)
Author = Column(TEXT)
+class Location(Base):
+ __tablename__ = 'Location'
+ id = Column(Integer, primary_key=True, autoincrement=True)
+ userid = Column(Integer)
+ Bookcase = Column(Integer)
+ Shelf = Column(Integer)
+
+
# Connect to database and establish a session
-engine = create_engine('mysql+pymysql://library:jdSCAd6KEqfbpzh9NT4x@db.dandembinski.com:3306/Library')
+engine = create_engine('mysql+pymysql://library:jdSCAd6KEqfbpzh9NT4x@db.dandembinski.com:3306/Library',
+ pool_recycle=3600)
# engine.connect()
Session = sessionmaker(bind=engine)
@@ -42,10 +52,14 @@ async def root():
@app.post('/checkin/')
-async def checkin(isbn: str = Form(...)):
+async def checkin(isbn: str = Form(...), locationid: int = Form(...)):
info = await getMeta(isbn)
- session.add(Book(userid=1, Title=info['Title'], Author=info['Authors']))
- session.commit()
+ session.add(Book(userid=1, Title=info['Title'], Author=info['Authors'], locationid=locationid))
+ try:
+ session.commit()
+ except:
+ session.rollback()
+ raise
return {"Checked in": info['Title']}
@@ -71,6 +85,17 @@ async def lookup(isbn: str = Form(...)):
return {"Title": info['Title']}
+@app.post('/AddLocation/')
+async def checkin(BookCase: str = Form(...), Shelf: str = Form(...)):
+
+ location = []
+ session.add(Location(userid=1, Bookcase=BookCase, Shelf=Shelf))
+ session.commit()
+ location.append(BookCase)
+ location.append(Shelf)
+ return {"Location Added": location}
+
+
async def getMeta(isbn):
info = meta(isbn, service='wiki')
return info