@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))
在我提交表单时运行以下程序时,它会收到内部服务器错误。请帮帮我,真的很难纠正这个。