def user_delete(): """删除用户""" form = UserDeleteForm() if not form.validate(): response = {'status': False, 'messages': form.errors} else: response = User.delete_user(form) return make_response_with_headers(jsonify(response))
def user_register(): """注册用户""" form = UserRegisterForm() if not form.validate(): response = {'status': False, 'messages': form.errors} else: response = User.register_user(form) return make_response_with_headers(jsonify(response))
def user_login(): """登录用户""" form = UserLoginForm() if not form.validate(): response = {'status': False, 'messages': form.errors} return make_response_with_headers(response) else: response = User.login_user(form) return make_response_with_headers(jsonify(response))
def init_st_instance(): # init node # port = 9755 # for i in range(1024): # key = 'http://127.0.0.1:%s' % (port + i) # value = {'key': key, 'name': 'node%s' % i, 'status': '激活', 'add_time': datetime.datetime.now()} # node = Node(key, value) # node.add() # # # init proxy # for i in range(255): # key = '125.125.125.%s' % i # value = {'key': key, 'proxy': key, 'add_time': datetime.datetime.now(), # 'version': 1, # 'status': '未知', 'business': []} # proxy = Proxy(key, value) # proxy.add() st_instance.ins_user = User.loads(amount=None) st_instance.ins_cipher = Cipher.loads() st_instance.ins_node = Node.loads() st_instance.ins_task = Task.loads() st_instance.ins_proxy = Proxy.loads() st_instance.ins_master = Master.loads() st_instance.ins_activity = Activity.loads()
def load_user(user): """加载用户""" with open(pick_user, 'rb') as f: users = pickle.load(f) return User(user, users[user]) if user in users else None
def user_index(): """索引用户""" response = User.index_user() return make_response_with_headers(jsonify(response))
def user_logout(): """登出用户""" response = User.logout_user() return make_response_with_headers(jsonify(response))