当前,我正在尝试将form.html扩展为layout.html(具有模板)。我尝试利用{%extended“ layout.html”%}并使用{%block main%}和{%endblock%}。但是,这似乎不起作用。当我进入layout.html时,它将具有一个导航栏,其中包括:首页,表单,表格。但是,当我单击表单页面时,找不到404页面。有什么问题吗?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1, width=device-width">
<!-- http://getbootstrap.com/docs/4.1/ -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link href="/static/styles.css" rel="stylesheet">
<title>Survey</title>
</head>
<body>
<!-- http://getbootstrap.com/docs/4.1/components/navbar/ -->
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<a class="navbar-brand mb-1 h1" href="/">Survey</a>
<button aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" type="button" data-target="#navbarNav" data-toggle="collapse">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/form">Form</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/sheet">Sheet</a>
</li>
</ul>
</div>
</nav>
<!-- http://getbootstrap.com/docs/4.1/layout/overview/#containers -->
<main class="container-fluid p-5">
{% block main %}
{% endblock %}
</main>
</body>
</html>
THIS IS FOR form.html
{% extends "layout.html" %}
{% block main %}
<!-- http://getbootstrap.com/docs/4.1/content/typography/ -->
<h1 class="mb-3">Form</h1>
<!-- http://getbootstrap.com/docs/4.1/components/forms/ -->
<form action="/form" method="post">
<!-- TODO -->
<!-- http://getbootstrap.com/docs/4.1/components/buttons/ -->
<button class="btn btn-primary" type="submit">Submit</button>
</form>
<script>
/* TODO */
</script>
{% endblock %}
在终端内部,我期望使用layout.html模板呈现form.html页面。但是,我得到了 [2019-07-13T06:02:11.139Z]“获取/窗体”错误(404):“未找到”