Troubleshoot TemplateNotFound error from Flask under Gunicorn

前端 未结 3 1435
故里飘歌
故里飘歌 2021-02-19 10:23

I\'ve got a Flask app that I\'m trying to deploy using Gunicorn and nginx. However, although it works fine locally, it throws a TemplateNotFound error when I run in with Gunicor

3条回答
  •  春和景丽
    2021-02-19 11:07

    Are your templates in [app root]/templates/?

    If so, check to be sure your path is correct. Put this as the first line in the view that handles your homepage:

    return app.root_path
    

    If that's what you expect to see - or if you're using Blueprints or another method that changes the default Jinja Environment somehow - it's a little more complicated.

    Oddly, Jinja doesn't seem to have a jinja2.Environment.FileSystemLoader.get_search_path() method. I assumed it would have one :(

提交回复
热议问题