@@ -10,6 +10,7 @@ from .models import Resource | |||
from werkzeug.exceptions import abort | |||
from . import db | |||
from isbntools.app import * | |||
import requests | |||
# function to retrieve data about a single resource from the database | |||
def get_resource(resource_id): | |||
@@ -42,9 +43,18 @@ def get_filter_values(field): | |||
return field_filter | |||
def get_book_data(isbn): | |||
try: | |||
#try: | |||
book = meta(isbn) | |||
book.update(cover(isbn)) | |||
description = {'desc': desc(isbn)} | |||
book.update(description) | |||
# get highest-resolution book cover possible | |||
openl_url = 'https://covers.openlibrary.org/b/isbn/' + book['ISBN-13'] + '-L.jpg?default=false' | |||
request = requests.get(openl_url) | |||
if request.status_code != 200: | |||
book.update(cover(isbn)) | |||
else: | |||
book_cover = {'thumbnail': openl_url} | |||
book.update(book_cover) | |||
return book | |||
except: | |||
pass | |||
#except: | |||
# pass |
@@ -3,7 +3,7 @@ | |||
{% block content %} | |||
{% if book['thumbnail'] %} | |||
<img class="img-fluid mx-auto d-block" src={{ book['thumbnail'] }} alt="cover for {{ book['Title'] }}"> | |||
<img class="img-fluid mx-auto d-block py-3" src={{ book['thumbnail'] }} alt="cover for {{ book['Title'] }}"> | |||
{% else %} | |||
<div class="row"> | |||
<div class="col"> | |||
@@ -42,7 +42,7 @@ | |||
</th> | |||
<td> | |||
{% for author in book['Authors'] %} | |||
{{ author }}, | |||
{{ author }} | |||
{% endfor %} | |||
</td> | |||
{% else %} | |||
@@ -87,6 +87,16 @@ | |||
</td> | |||
</tr> | |||
{% endif %} | |||
{% if book['desc'] %} | |||
<tr> | |||
<th> | |||
Summary: | |||
</th> | |||
<td> | |||
{{ book['desc'] }} | |||
</td> | |||
</tr> | |||
{% endif %} | |||
{% else %} | |||
<!-- fields for books from database --> | |||
{% if resource['name'] %} |
@@ -5,4 +5,5 @@ flask-moment | |||
gunicorn | |||
pymysql | |||
markdown | |||
isbntools | |||
isbntools | |||
requests |