flask TemplateNotFound

Asked 2 years ago, Updated 2 years ago, 108 views

I created a program that loads and shows templates with Python flasks.

import flask;
app = flask.Flask(__name__);

@app.route('/')
@app.route('/home')
def hello():
    return flask.render_template('test.html')
app.run(debug=True);

However, I keep getting an error saying that I couldn't find the file in the 7th line

As I saw on the Internet, I made a tenplates folder containing html I even created an empty staytic folder, but the error jinja2.exception.TemplateNotFound continued. Below is the folder structure.

app
    |----templates
        Test.html
    |----staytic
        empty
    run.py

flask python template jinja2

2022-09-20 19:16

1 Answers

WSL Ubuntu 18.04 LTS python3.6.9 Flask == 1.1.2 The above code can be executed in the environment.

It looks good to check out the Python version and the typo of the operating system or folder name.


2022-09-20 19:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.