4

I'm trying to call the render_template method in flask to a template that is outside the current running directory

return render_template('../show_data.html',data=data)

You'll notice I tried to use '..' to go back in the directory structure but that is not working as I'm getting a error:

jinja2.exceptions.TemplateNotFound
Luis
  • 51
  • 3

1 Answers1

6

By default flask application looks for templates folder which located in same directory with application file. But if you want to change it:

app = Flask(__name__, template_folder='folder/to/template')

Or you can use blueprints to have separate template folder

main = Blueprint(__name__, 'main', template_folder='folder/to/template')

So the problem you are having because of this. Or maybe you can check here jinja loader

Community
  • 1
  • 1
metmirr
  • 4,234
  • 2
  • 21
  • 34