【发布时间】:2021-03-08 23:55:21
【问题描述】:
这是我的 base.html 模板:
<head>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet">
<link href="/static/styles.css" rel="stylesheet">
<title>{% block title %}{% endblock %}</title>
<ul>
<li><a href="/templates/index.html">Home</a></li>
<li><a href="/templates/cheerbot.html">Cheerbot</a></li>
<li><a href="/templates/encouragement.html">Encouragement</a></li>
</ul>
</head>
<body>
<div class="jumbotron">
<div class= "chin">
<bodyblack>C H I N U P, C H E E R U P</bodyblack>
</div>
<h1>CHEERBOT</h1>
<bodyblack>________________________________________________________</bodyblack>
</div>
{% block body %}
{% endblock %}
</body>
这是名为cheerbot.html 的子模板:
{% extends "base.html" %}
{% block title %}Cheerbot{% endblock %}
{% block body %}
<h1>testing</h1>
{% endblock %}
这是python代码:
from flask import Flask, flash, jsonify, redirect, render_template, request, session
app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True
@app.route('/cheerbot')
def cheerbot():
return render_template('cheerbot.html')
但是,网页的标题没有显示“Cheerbot”,网页最终显示的是原始代码,而不是扩展基本模板。它有什么问题?提前致谢。
网页显示给我的图片
【问题讨论】:
标签: javascript html flask jinja2