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

Time:09-08

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

CodePudding user response:

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.

  • Related