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)
网友评论