can read from html forms now. Added simple html page to submit isbn to lookup.
This commit is contained in:
5
index.html
Normal file
5
index.html
Normal 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>
|
||||||
8
main.py
8
main.py
@@ -1,4 +1,4 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI, Form
|
||||||
from isbnlib import meta
|
from isbnlib import meta
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
@@ -19,7 +19,7 @@ async def checkout(isbn):
|
|||||||
return{"Checked Out": isbn}
|
return{"Checked Out": isbn}
|
||||||
|
|
||||||
|
|
||||||
@app.put('/lookup/{isbn}')
|
@app.post('/lookup')
|
||||||
async def lookup(isbn):
|
async def lookup(isbn: str = Form(...)):
|
||||||
info = meta(str(isbn), service='wiki')
|
info = meta(isbn, service='wiki')
|
||||||
return{"Title": info['Title']}
|
return{"Title": info['Title']}
|
||||||
|
|||||||
Reference in New Issue
Block a user