controllers.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:secret-weapon 作者: junorouse 项目源码 文件源码
def display_new_algorithm():
    form = CreateAlgorithmForm(request.form)
    if request.method == 'POST' and form.validate():
        name = form.name.data
        code = form.code.data
        current_app.logger.info('Adding a new algorithm %s.', (name))
        algorithm = Algorithm(name, current_user.id, code=code)
        try:
            db.session.add(algorithm)
            db.session.commit()
            flash('Algorithm successfully created.')
            return redirect(url_for('setting.display_index'))
        except exc.SQLAlchemyError as e:
            flash('Algorithm was not created.')
            current_app.logger.error(e)

    return render_template('setting_new_algorithm.html', form=form)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号