代码拉取完成,页面将自动刷新
同步操作将从 吕焱飞/employees 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import json
from flask import Flask, render_template, request
from your_code_here.DataBaseManager import DataBaseManager
from util.Checker import Checker
app = Flask(__name__)
manager = DataBaseManager()
checker = Checker()
@app.route('/')
def index():
data_list = manager.query_info()
return render_template('index.html', data_list=data_list)
@app.route('/add', methods=['POST'])
def add_info():
info = request.json
if not checker.check_add_fields_exists(info):
return json.dumps({'success': False, 'reason': '字段不完整'}, ensure_ascii=False)
fail_reason = checker.check_value_valid(info)
if fail_reason:
return json.dumps({'success': False, 'reason': fail_reason}, ensure_ascii=False)
info['deleted'] = 0
insert_result = manager.add_info(info)
return json.dumps({'success': insert_result})
@app.route('/update', methods=['POST'])
def update_info():
info = request.json
if not checker.check_update_fields_exists(info):
return json.dumps({'success': False, 'reason': '字段不完整'}, ensure_ascii=False)
people_id = checker.transfer_people_id(info['people_id'])
if people_id == -1:
return json.dumps({'success': False, 'reason': 'ID必需为数字'})
dict_tobe_updated = info['updated_info']
fail_reason = checker.check_value_valid(dict_tobe_updated)
if fail_reason:
return json.dumps({'success': False, 'reason': fail_reason}, ensure_ascii=False)
update_result = manager.update_info(people_id, dict_tobe_updated)
return json.dumps({'success': update_result})
@app.route('/delete/<people_id>', methods=['GET'])
def delete(people_id):
people_id = checker.transfer_people_id(people_id)
if people_id > 0:
delete_result = manager.del_info(people_id)
return json.dumps({'success': delete_result})
return json.dumps({'success': False, 'reason': 'ID必需为数字'})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。