我的 Flask 应用使用了 Blueprint,但在 Chrome 和 IE 中无法显示 CSS 文件。
调试信息如下:
资源被解释为样式表,但传输的 MIME 类型为 text/html
我的应用有以下文件:
app.py
templates/index.html
static/style.css
在我的app.py
文件中:
app = Blueprint("conf_manager",
__name__,
template_folder="templates",
static_folder="static",
static_url_path="/static")
在我的
index.html
中:<link rel="stylesheet" type="text/css" href="{{ url_for('conf_manager.static', filename='style.css') }}" />
我使用Chrome进行调试,发现浏览器能够获取文件,但类型是text/html
而不是text/css
(但JavaScript的类型没问题)。
因此,我想知道为什么会出现这种情况以及如何解决它。