简体   繁体   English

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

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

I was messing around with learning python myself, was working on a little HTML website using python.我自己在忙于学习 python,正在使用 python 开发一个小的 HTML 网站。 Anyone could please explain the differences between the two applications below?任何人都可以解释以下两个应用程序之间的区别吗?

When it's written like this it doesn't work.当它这样写时,它不起作用。 (this is an example I got from the top result from google) (这是我从谷歌的最高结果中得到的一个例子)

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

doesn't works不起作用

but when I include the full link .html但是当我包含完整的链接 .html

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

it works?有用?

Ok so let's say you have index.html and index.png your code does not what file is needed.好的,假设您有 index.html 和 index.png 您的代码不需要什么文件。 Even though you only have one file it is sort of safety to stop your code from opening other files.即使您只有一个文件,阻止您的代码打开其他文件也是一种安全。 The files extension is apart of the file.文件扩展名是文件的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM