Forums

flask simple app, templateNotFound

Hey, simple flask app getting error: jinja2.exceptions.TemplateNotFound: templates/index.html

html is in that location, what's wrong?

app = Flask(__name__)

@app.route('/')

def home():
    return render_template('templates/index.html')


if __name__ == '__main__':
    app.run()

[edit by admin: formatting]

[Deleted - as I didn't read properly]

Could you try using a fully qualified filename - so, '/home/shaika/your_app_name/templates/index.html'?

I think Flask uses the directory templates by default. So your code should be

    return render_template('index.html')

checked all these things but it still says TemplateNotFound

Can I take a look at your files? We can see them from our admin interface, but we always ask for permission first.

app = Flask(name, template_folder='/home/shaika/your_app_name/templates')

@app.route('/')

def home(): return render_template('index.html')

if name == 'main': 
    app.run()

This will solve your problem.

what's the answer then??

@audiolec What is the question?