1

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.