Menu Close

How to fix Python Flask raising TemplateNotFound error even though template file exists?

Sometimes, we want to fix Python Flask raising TemplateNotFound error even though template file exists.

In this article, we’ll look at how to fix Python Flask raising TemplateNotFound error even though template file exists.

How to fix Python Flask raising TemplateNotFound error even though template file exists?

To fix Python Flask raising TemplateNotFound error even though template file exists, we can set the template_folder to the folder with the templates in our project.

For instance, we write

app = Flask(__name__, template_folder='template') 

to set the template_folder argument to the path string relative to our project folder.

Conclusion

To fix Python Flask raising TemplateNotFound error even though template file exists, we can set the template_folder to the folder with the templates in our project.

Posted in Python, Python Answers