Exemplo n.º 1
0
def submit():
    form = MessageForm()
    if form.validate_on_submit():
        uid = uid_generator()
        while Message.query.filter_by(uid=uid).first() is not None:
            uid = uid_generator()
        message = Message(ip=request.remote_addr,
                          uid=uid,
                          text=form.message.data,
                          )
        db_session.add(message)
        db_session.commit()
        flash(uid, 'message_created')
        return redirect(url_for('index'))
    return render_template('submit.html', form=form)
Exemplo n.º 2
0
def message_detail(uid):
    message = Message.query.filter_by(uid=uid).first_or_404()
    db_session.delete(message)
    db_session.commit()
    return render_template('message_detail.html', message=message)