Python获取客户端IP地址
2019-05-28 本文已影响0人
LeslieLiang
获取客户端IP地址
if 'HTTP_X_FORWARDED_FOR' in request.META:
ipaddress = request.META['HTTP_X_FORWARDED_FOR']
else:
ipaddress = request.META['REMOTE_ADDR']
if 'HTTP_X_FORWARDED_FOR' in request.META:
ipaddress = request.META['HTTP_X_FORWARDED_FOR']
else:
ipaddress = request.META['REMOTE_ADDR']