Skip to content
Advertisement

Why does my flask route show 404, after trying to link it into my starting page

enter image description here[

    @app.route("/search")
    def search():
        return render_template("/search.html")
][1]

How my search route appears

This the code used in my app.py. I have tried

{href=”./search.html”}

but there is no difference.

Edit How my project folder looks like Edit 2: My mistake in the routing

Advertisement

Answer

EDIT

to link your routes from within your HTML pages, you can use the url_for function inside double curly brackets. so in your case it would be something like this:

<a href="{{url_for('search')}}">Search Page</a>

note that the value you pass into url_for is the name of the function for your route, not the route itself.

see this answer for more info.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement