【发布时间】:2021-01-18 10:49:41
【问题描述】:
所以我尝试建立一个(小)网站(用于学习目的)并且在使用块时遇到了一些问题。 我觉得问题很明显,但我无法弄清楚。 这是我的代码:
# main.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def home():
return render_template("main.html")
if __name__ == "__main__":
app.run(debug=True)
# main.html
<!DOCTYPE html>
<head>
<title>
{% block title %}{% endblock %}
</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
# mainexdended.html
{% extends "main.html" %}
{% block title %}Test{% endblock %}
{% block content %}
<h1> Content Test </h1>
{% endblock %}
现在,当我运行代码时,我只是得到一个空白页。 mainextended.html 中定义的所有内容都会被忽略。 我该如何改变呢?
【问题讨论】: