def mock_data(): ''' 模拟数据 imooc.com { "key":"value" } ''' return_data = { "message": None } mock_data = read_json() url = request.form.get("url") data = request.form.get("data") try: data = json.loads(data) mock_data[url] = data except Exception: return_data['message'] = "你传递的数据不是json格式" return json.dumps(return_data) try: print("--->", mock_data) write_value(mock_data, file_name="/Config/user_data.json") except Exception: return_data['message'] = "写入数据失败" json.dumps(return_data) return_data['message'] = "写入成功" return json.dumps(return_data)
def get_cookie_value(cookie_key): """ cookieを取得 :param cookie_key: :return: """ data = read_json("/Config/cookie.json") return data[cookie_key]
def write_cookie(data, cookie_key): """ cookieを書き込む :param data: :param cookie_key: :return: """ data1 = read_json("/Config/cookie.json") data1[cookie_key] = data write_value(data1)
def write_cookie(data, cookie_key): #写入cookie data1 = read_json("/Config/cookie.json") data1[cookie_key] = data write_value(data1)
def get_cookie_value(cookie_key): #获取cookie data = read_json("/Config/cookie.json") return data[cookie_key]
def get_header(): data = read_json("/Config/header.json") return data
def get_header(): header = read_json("/Config/header.json") return header
def get_cookid_valus(cookie_key): """读取COOKie""" data=read_json("/Config/cookie.json") return data[cookie_key]
def write_valuse(data,cookie_key): """写入cookie""" data1=read_json("/Config/cookie.json") data1[cookie_key]=data write_Cookie(data1)
def get_token_value(token_key): """获取token""" data = read_json("token.json") # 调用read_json获取token return data[token_key]
def write_token(data, token_key): """写入token到token.json文件中""" data1 = read_json("token.json") # 读取后更新token的value data1[token_key] = data write_value(data1) # 写入