add pages for books
This commit is contained in:
parent
aaad29dc45
commit
d560380166
8
templates/book.html
Normal file
8
templates/book.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!doctype html>
|
||||
<title>{{book["title"]}}</title>
|
||||
{% if book["image"] is not equalto "" %}
|
||||
<p> cover: <img src="{{ url_for('static', filename="library_files/" + book["image"]) }}"> </p>
|
||||
{% endif %}
|
||||
{% for datum in (book|dictsort) %}
|
||||
<p> {{datum[0]}}: {{ datum[1] }} </p>
|
||||
{% endfor %}
|
6
test.py
6
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/<int:id>")
|
||||
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')
|
||||
|
Loading…
Reference in New Issue
Block a user