def addAccessLog(): target = AppAccessLog() target.target_url = request.url target.referer_url = request.referrer target.ip = request.remote_addr target.query_params = json.dumps(request.values.to_dict()) if 'current_user' in g and g.current_user is not None: target.uid = g.current_user.uid target.note = g.current_user.nickname target.ua = request.headers.get('User-Agent') target.created_time = getCurrentDate() db.session.add(target) db.session.commit() return True
def add_access_log(): """ 将访问url添加到日志 """ target = AppAccessLog() target.target_url = request.url target.referer_url = request.referrer target.ip = request.remote_addr target.query_params = json.dumps(request.values.to_dict()) if 'current_user' in g and g.current_user: target.uid = g.current_user.uid target.ua = request.headers.get('User-Agent') target.created_time = get_current_time() db.session.add(target) db.session.commit() return True
def addAccessLog(): """ 访问记录 """ target = AppAccessLog() target.target_url = request.url # 请求的链接 target.referer_url = request.referrer target.ip = request.remote_addr # 远程地址 target.query_params = json.dumps(request.values.to_dict( )) # 使用json的方式传进来。dumps将字符串解析成json。to_dict():请求的数据转化成字典 if 'current_user' in g and g.current_user is not None: target.uid = g.current_user.uid target.ua = request.headers.get("User-Agent") # 用户头信息 target.created_time = getCurrentData() db.session.add(target) db.session.commit() return True