Я начинаю использовать Flask и обнаруживаю следующую ошибку:
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'endblock'.
Я не знаю точно, где ошибка, я уже переделал код, но У меня все та же проблема! Вот код:
app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return "Hello, World!"
@app.route("/page1")
def page1():
return render_template("page1.html")
@app.route("/page2")
def more():
return render_template("page2.html")
макет. html
<html>
<head>
<title> My website </title>
</head>
<body>
<h1> {$ block heading %}{% endblock heading %}} </h1>
{% block body %}
{% endblock body %}
</body>
</html>
page1. html
{% extends "layout.html" %}
{% block heading %}
First Page
{% endblock heading %}
{% block body %}
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<a href="{{ url_for('more') }}"> Leia Mais. </a>
{% endblock body %}