Python program for searching books returns

Skip to first unread message

Arnon Rodrigues

Jun 4, 2021, 4:08:40 PMJun 4
to Google Visualization API
Hi, I have a Python program where you can create your own bookshelf. Database and everything are working fine, everything is almost done. But I noticed that there are some books (durinthe search) that loads forever and Terminal returns me (infinite times):
DEBUG: "GET /books/v1/volumes?q=moby%20dick HTTP/1.1" 200 None
DEBUG: Starting new HTTPS connection (1):

Here is my code:
Captura de Tela 2021-06-04 às 17.02.52.png
@app.route('/search', methods=["GET", "POST"])
def search():
    if request.method == "POST":
        while True:
                seek = request.form.get("seek")
                response = requests.get(url)
                search = response.json()
                seek = search['items']
                infobooks = []
                    for i in range(len(seek)):
                            "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, KeyErrorTypeErrorValueError):
        return render_template("index.html")

After this, I just display the result in the HTML by doing this:
Captura de Tela 2021-06-04 às 17.04.47.png

The final result is very beautiful, mainly when it works:
Captura de Tela 2021-06-04 às 17.06.12.png

The problem occurs when I search for a book with two names like "Harry Potter" or "Moby Dick", but it sometimes it occurs with one name too.

Does anyone could help me?

Thanks in advance!
Reply all
Reply to author
0 new messages