美文网首页Python 学习
获得请求主机IP

获得请求主机IP

作者: bianruifeng | 来源:发表于2020-01-14 19:50 被阅读0次
    from falsk import request
    
    def get_request_ip():
        '''获取请求方的ip'''
        try:
            ip = request.remote_addr
            logging.error('------ ip = %s ------' % ip)
            return ip
        except Exception as e:
            logging.error(e)
    
    
    def get_my_ip():
        '''获取本机的ip'''
        try:
     
            name = socket.getfqdn(socket.gethostname())
            ip = socket.gethostbyname(name)
            logging.error('------ ip = %s ------' % ip)
            return ip
        except Exception as e:
            logging.error(e)
    

    相关文章

      网友评论

        本文标题:获得请求主机IP

        本文链接:https://www.haomeiwen.com/subject/kpjsectx.html