Exemplo n.º 1
0
 def post(self):
     body = request.get_json()
     action = body.get('action')
     data = body.get('data')
     if action == 'login':
         return user_manager.login_user(action, data)
     else:
         return flask_utils.res_f('AUTH no action')
Exemplo n.º 2
0
 def post(self):
     body = request.get_json()
     action = body.get('action')
     data = body.get('data')
     if action == 'user_check':
         return flask_utils.res_s(action=action, data=self.c_user)
     else:
         return flask_utils.res_f('AUTH no action')
Exemplo n.º 3
0
 def post(self):
     body = request.get_json()
     action = body.get('action')
     data = body.get('data')
     if action == 'list_file':
         rst = file_manager.list_my_file(data.get('user_name'))
         return flask_utils.res_s(action=action, data=rst)
     else:
         return flask_utils.res_f('FileResource no action')
Exemplo n.º 4
0
 def post(self):
     body = request.get_json()
     action = body.get('action')
     data = body.get('data')
     if action == 'init_web_data':
         return user_manager.init_web_data(action, self.c_user)
     # elif action == 'register':
     #     return user_manager.register_user(action, data, self.c_user)
     # elif action == 'add_user':
     #     return user_manager.add_user(action, data, self.c_user)
     # elif action == 'del_user':
     #     return user_manager.del_user(action, data, self.c_user)
     # elif action == 'update_user':
     #     return user_manager.update_user(action, data, self.c_user)
     # elif action == 'query_user':
     #     return user_manager.select_user(action, data)
     else:
         return flask_utils.res_f('AUTH no action')
def upload_file():
    up_list = list()
    user_name = None
    token = request.headers.get("access-token")
    rst = jwt_utils.token_decode(token)
    if rst.get('code') == 0:
        try:
            user_name = rst.get('data').get('user_name')
        except Exception as e:
            print(e)
        # # 用户鉴权
        # payload = rst.get('data')
        # c_user = {
        #     'user_name': payload.get('user_name'),
        #     'nick_name': payload.get('nick_name'),
        #     'role': payload.get('role'),
        #     'login_time': payload.get('login_time')
        # }
    if user_name and request.method == 'POST' and 'media' in request.files:
        file_list = request.files.getlist('media')
        up_list = file_manager.upload_files(file_list, user_name)
    if up_list:
        return flask_utils.res_s(action='upload_file', data=up_list)
    return flask_utils.res_f(action='upload_file')