【发布时间】:2020-07-15 01:39:38
【问题描述】:
我花了将近一天的时间试图弄清楚为什么我的 css 文件不能与我的 html 文件一起使用。所有堆栈溢出的答案都对我不起作用。
在这一点上我能得到任何帮助,我将不胜感激。我正在运行安装了烧瓶并使用 pycharm 的 python 3.8.1。 Click here to see my file structure screenshot, 这是主要的python文件代码:
from flask import Flask , render_template,
app = Flask(__name__)
@app.route('/')
def index( ):
return render_template("index.html" )
if __name__ == '__main__':
app.run( debug=True)
这是 index.html 文件代码,我希望 CSS 显示在
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<h1> Title </h1>
<h2>Second headline</h2>
<body>This is an orange test6</body>
</head>
<body>
<link rel="stylesheet" type="text/css" href=" {{ url_for('static', filename=' style.css') }}">
</body>
</html>
这是我在 pycharm 中运行文件时看到的错误:
“GET / HTTP/1.1” 200 - “GET /static/%20style.css HTTP/1.1”404 -
这里是 CSS 代码:
h1{
color: yellow;
}
body {
color: orange;
}
h2 {
color: pink;
}
【问题讨论】:
标签: html css flask pycharm http-status-code-404