Troubleshoot TemplateNotFound error from Flask under Gunicorn

前端 未结 3 1414
故里飘歌
故里飘歌 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:14

    Today, I experienced identical problems after a long period of my Flask app behaving quite normally (ie not throwing TemplateNotFound exceptions). None of the approaches mentioned by others here hit the mark or seemed appropriate (eg app.debug, path manipulation).

    Instead, I tracked it down to the standard Flask app initialisation line:

    app = Flask(__name__)
    

    I had changed __name__ to another value (to get access to a named logger), not expecting for all this carnage to unfold :-) Don't change this value unless you are very familiar with Flask internals.

提交回复
热议问题