I have been searching for a solution to this problem since the past two hours and have seen similar questions here but the solutions don't seem to be working. I am a beginner in Flask and Pythonanywhere so I feel the solution could be something really silly that I might be missing.
The template is called givp.html and everything is organized this way: home > user > mysite > templates >givp.html and home>user>mysite>apllic.py
The code I've been using is:
app=Flask(__name__,template_folder='/home/user/mysite/templates')
return render_template('/home/user/mysite/templates/givp.html',lst=d)
Things are working fine on my local system but here I've been getting error messages. The last line of the error logs is:
File "/home/user/.local/lib/python2.7/site-packages/flask/templating.py", line 64, in get_source raise TemplateNotFound(template) TemplateNotFound: /home/user/mysite/templates/givp.html
You have already defined your template_folder
while creating app instance in
app=Flask(__name__,template_folder='/home/user/mysite/templates')
so you have to provide just a template name (not a full path) while calling render_template
.
Your code fixed:
app=Flask(__name__,template_folder='/home/user/mysite/templates')
return render_template('givp.html',lst=d)