这个为啥报错呢?

来源:5-3 模板的继承之包含语法

热爱编程学习

2021-10-22 01:33:38

article.html
{% extends 'index.html' %}
{% block content %}

        <aside class="left">
            左侧内容区域--手记
        </aside>
        <aside class="right">
            右侧内容区域-- 手记
            {% include "sidebar.html" %}
        </aside>
{% endblock %}


sidebar.html
<p> 课程推荐 </p>


index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页-慕课网</title>
    <style type="text/css">
        .container {
            width: 600px;
            height: 500px;
            margin: 0 auto;
        }

        header {
            background: aqua;
        }

        article {
            background: azure;
            height: 500px;
        }
        article.left{
            background-color: blue;
            width: 60%;
        }
        article.right{
            background-color: rebeccapurple;
            width: 40%;
            float: left;
        }

        footer {
            background-color: coral;
        }
    </style>
    {% block head %}
    {% endblock %}
</head>
<body>
<div class="container">
    <header>
        页面头部[用户登录信息]
    </header>
    <article>
        {%block content%}
        首页课程内容
        {% endblock %}
    </article>
    <footer>页面底部</footer>
</div>
</body>
</html>


wenda.html
{% extends 'index.html' %}
{% block content %}
        <aside class="left">
            左侧内容区域--问答
        </aside>
        <aside class="right">
            右侧内容区域--问答
            {% include "sidebar.html"%}
        </aside>
{% endblock %}



@app.route('/wenda')
def add():
    return render_template('wenda.html')

https://img.mukewang.com/climg/6171a45f09c6b74012970690.jpg

写回答

1回答

好帮手慕燕燕

2021-10-22

同学,你好!检查一下代码中是否有同名的add()函数,如果有,修改成不同的函数名即可,老师这边运行同学提供代码是正常的

https://img.mukewang.com/climg/617226420924cf0011530593.jpg

祝:学习愉快!

0

0 学习 · 2433 问题

查看课程