Esempio n. 1
0
def login():
    user_name = request.form['username']
    pwd = request.form['password']
    hl = hashlib.md5()
    hl.update(pwd.encode(encoding='utf-8'))
    print(user_name, hl.hexdigest())
    if user_name == 'admin' and hl.hexdigest(
    ) == 'd6d2c08b5e680606776e1a8ea1c9fdbd':
        user = {'userName': user_name}
        print("The use exist,create a token return to page")
        token = token_utils.create_token(user)
        user['token'] = token
        # 获取用户的基本信息
        return Result(data=user).get_json()
    else:
        return Result(code=1, message='用户名或密码错误!').get_json()
Esempio n. 2
0
def query():
    begin_tm = request.form['begin']
    end_tm = request.form['end']
    page = request.form['page']
    limit = request.form['limit']
    begin = int(page) * int(limit) - int(limit)
    end = int(page) * int(limit)
    count = len(port_service.get_all_port().items())
    print(count)
    # 获取出所有的数据
    order = port_service.query_valid_port_info(begin_tm, end_tm, begin, end)
    return Result(data=order, count=count).get_json()
Esempio n. 3
0
def auth_filter():
    # 判断是否需要验证权限,如果不需要直接放行None为不需要权限
    token = do_need_token()
    if token is None:
        # 直接放行
        return
    else:
        # 验证权限
        if utils_token.valid_token(token) is not False:
            # 验证token是否有效
            print("validate the token,if it were valid,we pass the querst")
            return
        else:
            url = request.url.split("?")[0]
            if url.find("/login") != -1:
                return
            else:
                return Result(code=3, message="请登录重新登录!").get_json()
Esempio n. 4
0
def destroy():
    port_service.destroy_port_info(request.form)
    return Result(code=0, message='销毁成功').get_json()
Esempio n. 5
0
def overdue():
    port_service.overdue_port_info(request.form)
    return Result(code=0, message='这个数据已过期').get_json()
Esempio n. 6
0
def saveOrUpdate():
    dic = deal_form()
    port_service.save_update_port_info(dic)
    return Result(code=0, message='修改成功').get_json()
Esempio n. 7
0
def get_port():
    valid = port_service.get_valid_ports()
    return Result(data=valid).get_json()