Skip to content
Sign upLog in
← Back to Community

Flask render_template

Profile icon
IslandDeveloper

I'm currently extending a template ("flask-boilerplate") created by @timmy_i_chen. I'm encountering an issue when trying to use the render_template function. I have a folder called "templates" and inside there is an html file ("index.html"). However when I reference the file using the function call it says that "jinja2.exceptions.TemplateNotFound: index.html". Here is a link https://repl.it/@IslandDeveloper/flask-boilerplate. Thanks for any help you can provide.

Answered by amasad [earned 5 cycles]
View Answer
Voters
Profile icon
Pragyan-JJ
Profile icon
xXAIbotXx
Profile icon
coderash
Profile icon
meijeronfire
Profile icon
Theo666
Profile icon
EdRandall
Profile icon
IslandDeveloper
Comments
hotnewtop
Profile icon
amasad

Here's an alternative fix, you can manually set root_path on the flask call like so https://repl.it/@amasad/flask-template

Profile icon
IslandDeveloper

@amasad
thanks, I'll give it try on my next try and let you know how it went.

Profile icon
timmy_i_chen

Oof. Just add a any empty .py file and it should work. This is an inconsistency caused by our "project mode/eval mode" discrepancies. Sorry for the confusion!

Profile icon
IslandDeveloper

@timmy_i_chen thanks for the swift reply, I'll give it a spin!

Profile icon
IslandDeveloper

@timmy_i_chen this worked well, thanks.

Profile icon
meijeronfire

@timmy_i_chen i tried, but it did not work. see here
https://repl.it/@meijeronfire/yesssssss

Profile icon
EdRandall

Am having a similar issue, trying to follow http://flask.pocoo.org/docs/1.0/quickstart/#rendering-templates and https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-ii-templates-legacy
Had tried using template_folder='templates' but no joy, but adding root_path='.' from

@amasad
worked.