Exemplo n.º 1
0
def get_top_books_info():

    popular_books = get_n_popular_books(n=20)

    books_serialized = Book.serialize_list(popular_books)
    for book in books_serialized:
        del book['ratings']

    return jsonify(books_serialized)
Exemplo n.º 2
0
def search_books_by_author():  # pragma: no cover

    author = request.args.get("author")

    if author:
        books_by_author = get_books_by_author(author)
        books_by_author_serialized = Book.serialize_list(books_by_author)
        for book in books_by_author_serialized:
            del book['ratings']

        return jsonify(books_by_author_serialized)

    else:
        return "No books found."
Exemplo n.º 3
0
def search_books_by_title():  # pragma: no cover

    title = request.args.get("title")

    if title:
        books_by_title = get_book_by_title(title)
        books_by_title_serialized = Book.serialize_list(books_by_title)
        for book in books_by_title_serialized:
            del book['ratings']

        return jsonify(books_by_title_serialized)

        # return jsonify({"books": books_by_title})

    else:
        return "No books found."