문제

My structure for files is this.

-App
    -services
        - __init__.py
        - app_file.py
    -templates
        - hello.html

Inside app_file.py, I've got

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

I know I have at least got a working "hello world" program, because this much worked

@app.route('/')
def hello():
    return 'Hello World'

However, when I attempt the templated html, I get this error.

jinja2.exceptions.TemplateNotFound

As I said, I'm almost positive it is something with my file structure, so I posted only what I feel is necesary to determine if I am right or not, but will post more upon request. Help please?

올바른 솔루션이 없습니다

다른 팁

templates should be a subfolder of where the services package, or you need to set a custom template_folder argument when creating the Flask() app object:

app = Flask(__name__, template_folder='../templates')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top