You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@app.route('/', methods=['GET', 'POST'])
def index():
form = HelloForm()
if form.validate_on_submit():
name = form.name.data
body = form.body.data
message = Message(body=body, name=name)
db.session.add(message)
db.session.commit()
flash('Your message have been sent to the world!')
return redirect(url_for('index'))
messages = Message.query.order_by(Message.timestamp.desc()).all()
return render_template('index.html', form=form, messages=messages)
The text was updated successfully, but these errors were encountered:
messages = Message.query.order_by(Message.timestamp.desc()).all()
移动到最后的return之前。The text was updated successfully, but these errors were encountered: