Python Flask url_for-不正确的静态文件夹路径

Python Flask url_for-不正确的静态文件夹路径,python,flask,Python,Flask,我正在尝试使用Flask将图像添加到我的quick.html页面,方法是: <img src='{{url_for('static', filename='img/question-mark.png')}}' alt='' > app.py from flask import Flask, render_template app = Flask(__name__) @app.route('/') def homepage(): return render_templat

我正在尝试使用Flask将图像添加到我的quick.html页面,方法是:

<img src='{{url_for('static', filename='img/question-mark.png')}}' alt='' >
app.py

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def homepage():
    return render_template("main.html")

@app.route('/quiz/')
def quiz():
    return render_template("quiz.html")

if __name__=="__main__":
    app.run(debug=True)

编写静态图像源不需要Jinja脚本。只要写下:

<img src="/static/img/question-mark.png">


所有静态资源都会在
/static

下自动提供。您是否从flask导入了url\u?请不要将“”和“”混在一起,你能把它们分开吗?看这个例子:
<img src="/static/img/question-mark.png">