简体   繁体   中英

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

I was messing around with learning python myself, was working on a little HTML website using python. 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

@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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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