【发布时间】:2017-05-19 23:05:18
【问题描述】:
我有一个包含模板和静态文件的 Flask 蓝图。模板正确呈现,但链接的 CSS 文件返回 404 未找到。如何提供位于蓝图文件夹下的静态文件?
app/
__init__.py
auth/
__init__.py
static/
style.css
templates/
index.html
auth = Blueprint('auth', __name__, template_folder='templates')
@auth.route('/')
def index():
return render_template('index.html')
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
【问题讨论】: