烧瓶不';我看不到我的css文件
为了开始学习Flask,我创建了名为first_Flask_exp的项目,其结构如下:烧瓶不';我看不到我的css文件,css,flask,Css,Flask,为了开始学习Flask,我创建了名为first_Flask_exp的项目,其结构如下: first_flask_exp --first_flask_exp.py --templates ----entry.html --static ----images ------checkered.png ----css ------entry-style.css 第一个\u flask\u exp.py包含以下代码: from flask import Flask, render_template, g
first_flask_exp
--first_flask_exp.py
--templates
----entry.html
--static
----images
------checkered.png
----css
------entry-style.css
第一个\u flask\u 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)
问题是,只有当我将css文件放入静态文件夹(不在任何子文件夹中)并编辑指向它的链接时,我的模板主体才会呈现红色,如下所示:
first_flask_exp
--first_flask_exp.py
--templates
----entry.html
--static
----images
------checkered.png
----css
------entry-style.css
{{url_for('static',filename='entry-style.css')}
请帮助我存储资源,如良好做法建议=)
提前感谢。我还应该补充一点,Chrome的firebug显示错误GET 404(未找到)。您提供的代码似乎对我来说运行良好。身体的背景是红色的,目录结构正常。嗯。。我刚刚从PyCharm直接重新创建了css文件夹,现在它可以工作了!谢谢你的帮助。听起来删除这个问题是个好主意——这对未来的访问者没有用处。
body {
background: red;
}