【发布时间】:2013-07-16 14:10:01
【问题描述】:
我故意删除了 app = Flask(name) 中的 name 并收到此错误:
Traceback (most recent call last):
File "routes.py", line 4, in <module>
app = Flask()
TypeError: __init__() takes at least 2 arguments (1 given)
这是我来自 nettuts 的代码,这是我的代码:
from flask import Flask, render_template
app = Flask()
@app.route('/')
def home():
return render_template('home.html')
@app.route('/about')
def about():
return render_template('about.html')
if __name__ == '__main__':
app.run(debug=True)
我的问题是:这个至少需要 2 个参数的 init 方法在哪里?
【问题讨论】:
-
如果你想看 Flask 的实际代码你可以去 /venv/lib/python.27/site-packages/flask 所有你用 pip 安装的东西都在这里,如果你使用了 virtualenv,你应该做什么;)