【发布时间】:2015-06-15 19:58:20
【问题描述】:
下面的模板有问题:没有加载 CSS 文件。
我将“style.css”正确放置在“my_project/static/”中。
我只是尝试将HTML文件源代码中的<link rel=stylesheet ...>替换为“style.css”的代码,它可以工作。
有什么问题?
<!doctype html>
<title>{% block title %}Welcome{% endblock %} | MiniTwit</title>
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
<div class=page>
<h1>MiniTwit</h1>
<div class=navigation>
{% if g.user %}
<a href="{{ url_for('timeline') }}">my timeline</a> |
<a href="{{ url_for('public_timeline') }}">public timeline</a> |
<a href="{{ url_for('logout') }}">sign out [{{ g.user.username }}]</a>
{% else %}
<a href="{{ url_for('public_timeline') }}">public timeline</a> |
<a href="{{ url_for('register') }}">sign up</a> |
<a href="{{ url_for('login') }}">sign in</a>
{% endif %}
</div>
{% with flashes = get_flashed_messages() %}
{% if flashes %}
<ul class=flashes>
{% for message in flashes %}
<li>{{ message }}
{% endfor %}
</ul>
{% endif %}
{% endwith %}
<div class=body>
{% block body %}{% endblock %}
</div>
<div class=footer>
MiniTwit — A Flask Application
</div>
</div>
【问题讨论】:
-
为什么体外有一个div? - 那是蟒蛇吗?
-
请发布您的应用程序文件夹结构和应用程序配置的最小示例。这闻起来像是 Flask 没有正确解析静态文件的路径。
标签: jquery python html css flask