def users_add(): params = request.args if request.method == 'GET' else request.form if not params: return render_template('useradd.html') ''' username = params.get('username') password = params.get('password') gender = params.get('gender') hobby = params.getlist('hobby') department = params.get('department') filename = request.files.get('files') if filename: print filename.filename filename.save('/tmp/aa.txt') age = params.get('age') telphone = params.get('telphone') email = params.get('email') ''' if User.user_add(params): # flash("用户%s添加成功" % username) return redirect('/user/') else: error = '用户名已存在' return render_template('useradd.html', error=error)
def newuser(): params = request.args if request.method == 'GET' else request.form _is_ok, _error = User.user_add(params) return jsonify({'is_ok': _is_ok, 'error': _error})