Alp*_*eph 4 html python flask-sqlalchemy
我正在开发一个需要登录的 Flask-sqlalchemy Web 应用程序。仅当用户登录时,注销按钮才应在页面上可见。因此所有这些页面都扩展了layout.html 文件,如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Login</title>
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
{% block head %} {% endblock %}
</head>
<body>
{% block body %}
<style type="text/css">
#footer {
position : absolute;
bottom : 0;
}
</style>
{ % if session['logged_in'] %}
<div id="footer" style="width:300px;height:100px"><a href=" {{url_for('logout')}}" style="width:100%;background:#f1f1f1;">Logout</a></div>
{% endif %}
{% endblock %}
<script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
TemplateSyntaxError:遇到未知标签“endif”。Jinja 正在寻找以下标签:“endblock”。
需要关闭的最里面的块是“block”。
尽管已经指定了 endblock 和 if 标签请帮我解决这个问题
尝试删除 { 和 % 之间的空格
{ % if session['logged_in'] %}
Run Code Online (Sandbox Code Playgroud)
使它成为
{% if session['logged_in'] %}
Run Code Online (Sandbox Code Playgroud)