From 5a2f4da937f4fd0608293b4a26edca7eaba6e7ae Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 7 Jun 2021 02:31:54 -0400 Subject: [PATCH] Started on framework for library api. Can now look up book title by isbn. Also added test.py to experiment with the isbn lookup stuff. --- main.py | 16 +++++++++++++++- test.py | 10 ++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test.py diff --git a/main.py b/main.py index 85e525c..c8bf353 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,22 @@ from fastapi import FastAPI +from isbnlib import meta app = FastAPI() @app.get('/') async def root(): - return {"message": "Hello World"} \ No newline at end of file + return {"message": "Hello World"} + +@app.post('/checkin/{isbn}') +async def checkin(isbn): + return{"Checked in": isbn} + +@app.get('/checkout/{isbn}') +async def checkout(isbn): + return{"Checked Out": isbn} + +@app.put('/lookup/{isbn}') +async def lookup(isbn): + info = meta(isbn, service='Default') + return{"Title": info['Title']} diff --git a/test.py b/test.py new file mode 100644 index 0000000..ed3e46d --- /dev/null +++ b/test.py @@ -0,0 +1,10 @@ +from isbnlib import meta + + +isbn = '9780747532743' +infowiki = meta(isbn, service='wiki') +infoopenl = meta(isbn, service='openl') + + +print(infowiki) +print(infoopenl) \ No newline at end of file