def add_user(): username = request.form.get('username', '') password = request.form.get('password', '') age = request.form.get('age', '') _session_id = session['user']['id'] _session_username = session['user']['username'] # gender = request.form.get('gender','1') # hobby = request.form.getlist('hobby') # department = request.form.getlist('department') # img = request.files.get('img') # if img: # print img.filename # img.save('/tmp/kk.txt') # print request.form # print gender # print hobby # print department #检查用户信息是否合法 _is_ok, _error = User.validate_add_user(_session_username,username, password, age) if _is_ok: User.add_user(username, password, age) #检查ok,添加用户信息 #flash("用户%s添加成功!" %username) #return redirect('/users/') #跳转到用户列表 return json.dumps({'is_ok':_is_ok, "error":_error})