Reputation: 1506
While working on a project which I build using Flask and a Bootswatch theme which is a books website, letting users to register, log in and then search for books and when a users selects one of results it gives information about that book,but I found out that information page which I implemented wasn't loading the styling of page, contrary to all other pages which are working fine.
My application.py
for information page is:
@app.route("/book/<isbn>")
def book(isbn):
# getting the book from database
book = db.execute("SELECT * FROM books WHERE isbn=:isbn", {"isbn": isbn}).fetchone()
if book is None:
return render_template("failure.html", error="Please enter some query", code = "403!")
db.commit()
# giving details to webpage
return render_template("book.html", book = book)
as you can see I am using ISBN (International Standard Book Number), as a path for different books because each book has unique ISBN, thus I assume it is great for making links to different individual book page. and book.html looks something like this:
<!-- further exptending the layout page -->
{% extends "layout.html" %}
<!-- further extending the title -->
{% block title %}
Books: Book Page
{% endblock %}
<!-- further extending the body -->
{% block body %}
<h3 align="center"> {{book.title}} by {{book.author}}</h3>
<div>
<li>
Title: {{book.title}}
</li>
<li>
Author: {{book.author}}
</li>
<li>
ISBN: {{book.isbn}}
</li>
<li>
Year: {{book.year}}
</li>
</div>
{% endblock %}
Please figure out where I am going wrong.
Upvotes: 1
Views: 342
Reputation: 48
Problem is in first line here in application.py
it should be
@app.route("/<isbn>")
because /book/<isbn>
loads css from /book/static/bootstrap.min.css
.
Upvotes: 1