search

Home  >  Q&A  >  body text

python - url_for in flask template all point to 404 page?

The links using url_for in the template all point to the 404 page, such as:

<li><a href="{{ url_for('auth.logout') }}">登出</a></li>

Click the logout button to go to the 404 page

But if I use 127.0.0.1:5000/logout, I can log out

The results of url_for in the template file are None, so when clicking any link the URL becomes 127.0.0.1:5000/None. If such a route is added:

@main.route("/None")
def test():
    return "None"

Click on any link to jump to test

漂亮男人漂亮男人2742 days ago565

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-05-18 10:48:08

    Since you set all routes to /None, naturally only the view function corresponding to this route will be skipped, which is the test.

    reply
    0
  • Cancelreply