【发布时间】:2020-07-25 21:44:22
【问题描述】:
我的网站很小,但图标无法正常工作: 代码如下:
base.html
<html>
<head>
<link rel="icon" href="static/icon.png" sizes="32x32">
<title>
{% block title %}{{title}}{% endblock %}
</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="page_container">
{% block content %}
<div class="container-fluid" style="margin-top: 100px;">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-info" role="alert">{{message}}</div>
{% endfor %}
{% endif %}
{% endwith %}
{# application content needs to be provided in the app_content block #}
{% block app_content %}{% endblock %}
</div>
{% endblock %}
</div>
</body>
</html>
浏览器在此模板上显示图标:
关于.html
{% extends "base.html" %}
{% block app_content %}
<div id="about_author_photo">
<img src="static/VVphoto.jpg" height="400px" width="270px">
</div>
{% endblock %}
但它不是这样的:
诗歌.html
{% extends "base.html" %}
{% block app_content %}
{% for poem in poems.items %}
{% include "_poem.html" %}
{% endfor %}
<div class="pagination-links">
{% for page in poems.iter_pages() %}
{% if page %}
{% if page != poems.page %}
<a href="{{ url_for('poems', page_num=page) }}">{{ page }}</a>
{% else %}
<span style="color: white;">({{ page }})</span>
{% endif %}
{% else %}
<span class=ellipsis style="color: white;">…</span>
{% endif %}
{% endfor %}
</div>
{% endblock %}
以下是他们俩的观点:
@app.route('/')
@app.route('/about')
def about():
return render_template('about.html', title='З Гумором Про Все На Світі')
@app.route('/poems/<int:page_num>')
def poems(page_num):
poems = Poem.query.paginate(per_page=5, page=page_num, error_out=True)
return render_template('poems.html', title='Вірші', poems=poems)
我尝试将图标添加到 {% extends "base.html %} 行下的诗歌 tepmlate 但它不起作用
【问题讨论】: