I have created a basic web application to showcase book reviews. Upon a successful search, users are provided with links to book titles - when a link is clicked, the goal is to pass the ISBN of the selected book to the url_for method and then present the corresponding template.
However, when I run my Flask server, the output shows that no CSS is being rendered along with the following information:
"GET /book_data/0316769177 HTTP/1.1" 200 -
"GET /book_data/static/style/style.css HTTP/1.1" 404
In my 'search_results.html' file:
{% for book, isbn in book_dict.items() %}
<li>
<a id="book_link" href="{{ url_for('book_data', isbn=isbn) }}">{{ book }}</a>
</li>
{% endfor %}
In my 'application.py' file:
@app.route("/book_data/<isbn>", methods=["GET"])
def book_data(isbn):
valid_login = True
results = db.execute('SELECT * FROM books WHERE isbn = :isbn',
{'isbn': isbn}).fetchall()
book_info = results[0]
return render_template("book_data.html",
valid_login=valid_login,
book_info=book_info)
In my 'book_data.html' file:
{% extends "layout.html" %}
{% block login %}
<div>
<a class="login_link" href="{{ url_for('signup') }}">Sign Up</a>
{% if valid_login == True %}
<a class="login_link" href="{{ url_for('logout') }}">Logout</a>
{% endif %}
</div>
{% endblock %}
{% block body %}
<h> The CSS is not rendering properly on this page</h>
{% endblock %}
All the expected CSS styles are included in 'layout.html' and all other pages are displaying them correctly except this one.
When a link from 'search_results.html' is clicked, the URL displayed is as follows: 127.0.0.1:5000/book_data/0316769177