jinja2.exceptions.TemplateNotFound

Zaa*_*ise 2 python flask

我的项目中有以下结构: \myapp application.py \include
hello.html 所以文件夹 myapp 包含 application.py 和文件夹包含。文件夹包含包含 hello.html。以下代码:application.py

#!/usr/bin/python 2.7.6
# -*- coding:utf-8 -*-
import os
import sys
from flask import Flask,render_template
import psycopg2
app = Flask(__name__)

@app.route('/')
def fihoum():
    conn = psycopg2.connect(database="carto", user="postgres",
           password="daed5Aemo", host="192.168.12.54")
    cur = conn.cursor()
    cur.execute("SELECT * FROM carto.\"BADGES_SFR\"")
    rows = cur.fetchall()
    return render_template('hello.html', titre="Données du client
   BADGES_SFR !",mots=rows)

if __name__=="__main__":
    app.run(host=os.getenv('IP', '0.0.0.0'), 
            port=int(os.getenv('PORT',5000)),debug=True)
Run Code Online (Sandbox Code Playgroud)

以下代码 hello.html :

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>{{ titre }}</title>
    </head>

    <body>
        <h1>{{ titre }}</h1>
        <ul>
        {% for mot in mots %}
            <li>{{ mot }}</li>
        {% endfor %}
        </ul>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

问题:当我运行程序 application.py 时我有这个错误: jinja2.exceptions.TemplateNotFound

TemplateNotFound: hello.html 感谢您的帮助

Dan*_*iel 7

模板文件夹默认为templates\; 所以你应该重命名includetemplates.