Flask raises TemplateNotFound error even though template file exists

前端 未结 11 1423
别跟我提以往
别跟我提以往 2020-11-21 23:02

I am trying to render the file home.html. The file exists in my project, but I keep getting jinja2.exceptions.TemplateNotFound: home.html when I t

11条回答
  •  梦毁少年i
    2020-11-21 23:38

    When render_template() function is used it tries to search for template in the folder called templates and it throws error jinja2.exceptions.TemplateNotFound when :

    1. the html file do not exist or
    2. when templates folder do not exist

    To solve the problem :

    create a folder with name templates in the same directory where the python file is located and place the html file created in the templates folder.

提交回复
热议问题