@login_required
def search():
if request.method == "POST":
while True:
try:
seek = request.form.get("seek")
response = requests.get(url)
response.raise_for_status()
search = response.json()
seek = search['items']
infobooks = []
for i in range(len(seek)):
infobooks.append({
"book_id": seek[i]['id'],
"thumbnail": seek[i]['volumeInfo']['imageLinks']['thumbnail'],
"title": seek[i]['volumeInfo']['title'],
"authors": seek[i]['volumeInfo']['authors']
})
return render_template("index.html", infobooks = infobooks)
except (requests.RequestException, KeyError, TypeError, ValueError):
continue
else:
return render_template("index.html")