From 2182d31c92317121b6c92f4deac411c4dd59a5d0 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 7 Jun 2021 11:02:10 -0400 Subject: [PATCH] can read from html forms now. Added simple html page to submit isbn to lookup. --- index.html | 5 +++++ main.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..e2be9f4 --- /dev/null +++ b/index.html @@ -0,0 +1,5 @@ +
+ + + +
\ No newline at end of file diff --git a/main.py b/main.py index fdf3066..adc442a 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -from fastapi import FastAPI +from fastapi import FastAPI, Form from isbnlib import meta app = FastAPI() @@ -19,7 +19,7 @@ async def checkout(isbn): return{"Checked Out": isbn} -@app.put('/lookup/{isbn}') -async def lookup(isbn): - info = meta(str(isbn), service='wiki') +@app.post('/lookup') +async def lookup(isbn: str = Form(...)): + info = meta(isbn, service='wiki') return{"Title": info['Title']}