PyCharm's code editor shows the popup message Template file 'index.html' not found
when passing "index.html"
to render_template
. The template templates/index.html
exists. Accessing http://localhost:5000/
renders the template. How do I tell PyCharm that the template exists?
@app.route('/')
def index():
return render_template('index.html')
Make sure that you have a file called index. html in the directory where you have configured Flask to look for templates (it's usually a directory called 'templates' in your web app directory).
Flask looks for templates in the templates directory, which is called templates , so the name is important. Make sure you're inside the flask_app directory and run the following command to create the templates directory: mkdir templates.
To resolve the issue, simply create a folder name it “Templates”. Then move “index. html” into this newly created folder.
Right click on your templates directory, go to "Mark Directory as", and select "Template Directory".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With