【发布时间】:2012-05-30 04:57:46
【问题描述】:
我正在关注 Flask 快速入门指南。 http://flask.pocoo.org/docs/quickstart/#static-files 当我按照指南进行操作时,我遇到了这个错误。
/application
/__init__.py
/templates
/hello.html
@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)
>python _init_.py
Traceback (most recent call last):
File "_init_.py", line 4, in <module>
@app.route('/hello/')
NameError: name 'app' is not defined
【问题讨论】:
-
你只需要导入render_template。
from flask import Flask, render_template