-1

Trying to run a static html with FLask. I keep getting the error: TemplateNotFound: lucky.html

Ive examined another post similar at: Flask Template Not found however it did not help my problem. I have tried to move the templates directory around containing the lucky.html file with no luck

File path:

C:\Python27\flask_practice\templates
lucky.html
lucky.py

Python:

from flask import Flask, render_template


app = Flask(__name__)

@app.route('/')
def lucky():
    return render_template('lucky.html')

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

Html:

<html>
    <body>

        <p> Hello there </p>
        <p> Feeling lucky </p>
        <p> 7 </p>

    </body>
</html>
Chris
  • 387
  • 5
  • 18

1 Answers1

0

It looks like your directories are not set up correctly.

In my flask app, i'm using the following (project_folder/__init__.py):

app = Flask(__name__)

my_loader = jinja2.ChoiceLoader([
    app.jinja_loader,
    jinja2.FileSystemLoader(app.config["TEMPLATEDIR"]),
])
app.jinja_loader = my_loader

with TEMPLATEDIR = "templates".

My project looks like:

root
    project_folder/__init__.py
    templates/404.html
Kenjin
  • 136
  • 1
  • 4
  • had to do something different but it was because my directories were not setup correctly. thanks – Chris Jun 06 '17 at 04:58