Search code examples
pythonroutesapp-route

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?


Solution

  • Ok so let's say you have index.html and index.png your code does not know 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 file extension is a part of the file.