【发布时间】:2020-05-02 21:26:46
【问题描述】:
我正在尝试使用 Flask 访问页面,但未提供静态文件。
@app.route('/hello/',
methods=['GET','POST'])
def hello:
return render_template('hello.html')
我在浏览器上得到了 hello.html 页面,但所有静态文件路径都已更改为 localhost:5000/hello/static... 但如果我改为:
@app.route('/hello')
正确提供静态文件。 因此,每当我有任何带有正斜杠的路由时,它都会更改正在提供的静态文件,即
@app.route('/editFile/<int:id>')
静态文件将更改并在新路径下提供服务 localhost:5000/editFile/static/... Routes with / after makes all static files be searched with wrong paths
If no / is added after route then static files are loaded correctly
【问题讨论】: