Flask没有看到我的css文件

时间:2013-06-29 15:15:32

标签: css flask

为了开始学习Flask,我创建了一个名为first_flask_exp的项目,其结构类似于:

first_flask_exp
--first_flask_exp.py
--templates
----entry.html
--static
----images
------checkered.png
----css
------entry-style.css

first_flask_exp.py包含以下代码:

from flask import Flask, render_template, get_flashed_messages, url_for

app = Flask(__name__)

@app.route('/')
@app.route('/hello/')
@app.route('/hello/<name>/')

def show_entry():
    return render_template('entry.html')

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

唯一的模板entry.html包含:

<!DOCTYPE html>
<html>
<head>
    <title>Entry point</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/entry-style.css') }}" type="text/css" media="screen"/>

</head>
<body>
    ENTER
</body>
</html>

我的entry-style.css是:

body {
    background: red;
}

问题是,只有当我将css文件放入静态文件夹(不在任何子文件夹中)并且编辑链接时,我的模板的主体才会呈现为红色:

{{url_for('static',filename ='entry-style.css')}}

请帮我存储资源,例如良好实践建议=)

提前致谢。

0 个答案:

没有答案
相关问题