예제 #1
0
 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.ua = request.headers.get('User-Agent')
     target.created_time = getCurrentDate()
     db.session.add(target)
     db.session.commit()
     return True
예제 #2
0
    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