controllers.py 文件源码

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

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

    form.name.data = algorithm.name
    form.code.data = algorithm.code
    return render_template("setting_edit_algorithm.html", form=form)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号