我有一个简单的烧瓶应用程序:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('basic.html')
if __name__ == '__main__':
app.run(debug=True)
目录结构(按建议):--
\templates
\basic.html
\static
\basic.css
basic.py
我已经用以下方式连接了HTML中的CSS文件:——
<link rel="stylesheet" href="{{ url_for('static', filename='basic.css') }}">
问题是:即使在重新加载浏览器之后,我对CSS文件所做的更改也没有在我的应用程序/网站中发生,当我在开发者工具中查看源代码时,结果发现样式没有应用! 这是我的CSS文件:——
h2{
font-size: 50px;
color: red;
background-color: green;
}
p{
color: blue;
}
h3{
font-size: 100px;
color: green;
background-color: red;
}
h4{
color: purple;
background-color: blue;
}
这就是开发人员工具中显示的内容:——
h1{
font-size: 50px;
color: red;
background: green;
}
p{
color: blue;
}
我也看了其他答案(Here) 但我无法理解我到底做错了什么
编辑:在浏览器中导航到文件后,我也看不到更改:——
编辑2:好的!硬刷新方式(Ctrl+shift+R)正在工作,但每次进行更改时我都必须这样做<没有别的办法吗
正如您所知,这是flask框架中最大的问题之一。我没有找到解决这个问题的技术堆栈。但您可以清除所有浏览器cookies或清除本地主机上运行的历史记录。此外,如果您更改浏览器,它将正常工作
相关问题 更多 >
编程相关推荐