From d560380166f53be7a9c22a78522886cde5bf19ae Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 8 Aug 2015 19:31:48 -0400 Subject: [PATCH] add pages for books --- templates/book.html | 8 ++++++++ test.py | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 templates/book.html diff --git a/templates/book.html b/templates/book.html new file mode 100644 index 0000000..28fe906 --- /dev/null +++ b/templates/book.html @@ -0,0 +1,8 @@ + +{{book["title"]}} +{% if book["image"] is not equalto "" %} +

cover:

+{% endif %} +{% for datum in (book|dictsort) %} +

{{datum[0]}}: {{ datum[1] }}

+{% endfor %} diff --git a/test.py b/test.py index 0896042..fde6fe9 100644 --- a/test.py +++ b/test.py @@ -20,6 +20,7 @@ def updateData(): for book in collection.iter(ns + "entry"): bookout = {} + bookout["id"] = int(book.find(ns + "id").text) bookout["title"] = book.find(ns + "title").text if (book.find(ns + "title") != None) else "" bookout["isbn"] = book.find(ns + "isbn").text if (book.find(ns + "isbn") != None) else "" authors = [] @@ -36,6 +37,11 @@ def main(): data = updateData(); return render_template("main.html", books = data, attributes = attributes) +@app.route("/book/") +def book(id): + data = updateData(); + book = next((item for item in data if item["id"] == id), {}) + return render_template("book.html", book = book) if __name__ == "__main__": app.run(debug=True, host='0.0.0.0')