小编kbs*_*hir的帖子

werkzeug.routing.BuildError:无法为端点建立网址

我创建了一个Web API来呈现带有导航的网页。下面是我的代码

from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/testsite/')
def home():
    return render_template('home.html')
if __name__ == '__main__':
    app.run(debug=True)

@app.route('/about/')
def about():

        return render_template('about.html')

if __name__ == '__main__':
    app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)

以下是两个html模板的HTML代码

home.html

<!DOCTYPE html>
<html>
<body>
{% extends "layout.html" %}
{% block content %}
<div class="home">
<h1>My Personal Website</h1>
<p>Hi, this is my personal website.</p>
</div>
{% endblock %}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

about.html

<!DOCTYPE html>
<html>
<body>
{% extends "layout.html" %}
{% block content %}
<div class="about">
<h1>About me</h1>
<img …
Run Code Online (Sandbox Code Playgroud)

python flask

3
推荐指数
1
解决办法
5993
查看次数

标签 统计

flask ×1

python ×1