测开之路一百三十一:实现删除功能
实现前端点击删除,后端接收到参数后删除对应数据 视图: @app.route('/del/<id>/')def delete_feedback(id=0): """ 删除问题 ,前端传id""" conn = sqlite3.connect(DATABASE) c = conn.cursor() sql = "delete from feedback where ROWID = ?" c.execute(sql, (id,)) conn.commit() conn.close() return redirect(url_for('list')) 前端,绑定视图函数,并传入id {% extends 'base.html'%}{% block main_content %} <div class="row"> <table class="table table-hover"> <tr> <th>ID</th> <th>主题</th> <th>分类</th> <th>用户</th> <th>邮箱</th> <th>处理状态</th> <th>提交时间</th> <th>操作</th> </tr> {% for item in items %} <tr> <td>{{ loop.index }}</td><!--jinja模板提供的遍历序号功能--> <td>{{ item[1] }}<