没有尾部斜杠会导致Flask应用中出现404错误

时间:2017-08-16 10:28:27

标签: python python-3.x url flask

- 在不改变任何内容的情况下解决。当我知道导致它暂时不起作用的时候会更新 -

我在Flask上创建了一个没有尾部斜杠的URL的路径。这应该符合docs

timestamp = "temptime"

@app.route('/js/searchindex<time>.js')
def searchindex(time):
    return render_template('searchindex.js')

会发生什么情况是URL被重定向到带有斜杠的URL,这显然会导致404错误。因此http://127.0.0.1:5000/js/searchindextemptime.js变为http://127.0.0.1:5000/js/searchindextemptime.js/

我知道我可以将斜杠设置为not-strict以避免404,但我真的想要不带斜线。

0 个答案:

没有答案