can read from html forms now. Added simple html page to submit isbn to lookup.

This commit is contained in:
dan
2021-06-07 11:02:10 -04:00
parent 9bc6c6e9b5
commit 2182d31c92
2 changed files with 9 additions and 4 deletions

5
index.html Normal file
View File

@@ -0,0 +1,5 @@
<form action="http://127.0.0.1:8000/lookup" method="POST">
<label for="isbn"> </label>
<input name="isbn" id="isbn" value=" ">
<button>Submit</button>
</form>

View File

@@ -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']}