无法使用flask框架在python中运行此视图函数

时间:2015-12-14 17:32:30

标签: python flask

@app.route('/', methods=['GET', 'POST'])
def index():
    form = NameForm()
    if request.method == 'POST':
        user = User.query.filter_by(username=form.name.data).first()
        if user is None:
            user = User(username=form.name.data)
            db.session.add(user)
            db.session.commit()
            session['known'] = False
        else:
            session['known'] = True
        session['name'] = form.name.data
        form.name.data = ''
        return redirect('/')
    return render_template("index1.html", form=form, name=session.get('name'), known=session.get('known', False))

在我提交表单时运行以下程序时,它会收到内部服务器错误。请帮帮我,真的很难纠正这个。

0 个答案:

没有答案