python
config_error
ai_generated
true
jinja2.exceptions.TemplateNotFound: index.html
ID: python/flask-template-not-found
80%Fix Rate
89%Confidence
0Evidence
2024-08-28First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2.x | active | — | — | — |
| 3.x | active | — | — | — |
Root Cause
Template file missing from the configured templates folder, or the Flask app was created with a different root path.
generic中文
模板文件不在配置的templates目录中,或者Flask应用使用了不同的根路径创建。
Workarounds
-
95% success
app = Flask(__name__, template_folder='templates')
-
92% success
import os\napp = Flask(__name__, template_folder=os.path.join(os.path.dirname(__file__), 'templates'))
Dead Ends
Common approaches that don't work:
-
90% fail
Reload flag only affects caching, not missing files.
-
50% fail
Works but bypasses template inheritance and is unmaintainable.