关于@app.route("/index") 的新手问题

Newbie question regarding @app.route("/index")

我自己正在学习 python,正在使用 python 开发一个 HTML 小网站。谁能解释一下下面两个应用程序之间的区别?

这样写就不行了。 (这是我从 google 的最高结果中得到的一个例子)

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

不起作用

但是当我包含完整的 link .html

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

有效吗?

好的,假设您有 index.html 和 index.png,您的代码不知道需要什么文件。即使您只有一个文件,也可以安全地阻止您的代码打开其他文件。文件扩展名是文件的一部分。