【发布时间】:2017-01-27 12:38:24
【问题描述】:
我的背景图片仅适用于具有@app.route('/') 的模板。
<header class="intro-header" style="background-image: url('static/img/home.jpg')">
这在以下情况下非常有效:
@app.route('/')
def home():
return render_template('post.html')
一切正常。我明白了:
127.0.0.1 - - [19/Sep/2016 21:07:11] "GET /static/img/home.jpg HTTP/1.1" 304
但是当我使用相同的模板时:
@app.route('/post/')
def post():
return render_template('post.html')
我明白了:
127.0.0.1 - - [19/Sep/2016 21:15:23] "GET /post/static/img/home.jpg HTTP/1.1" 404 -
背景图片是空白的。
【问题讨论】:
-
提供站点相关链接:
url(/static/...)而不是文档相关