debug ip detection problem
This commit is contained in:
parent
844f08137c
commit
fc2e088ba1
@ -22,16 +22,13 @@ def MyIpView(request):
|
||||
|
||||
def DetectIpView(request, secret=None):
|
||||
|
||||
try:
|
||||
s = SessionStore(session_key=secret)
|
||||
except SessionStore.DoesNotExist:
|
||||
s = request.session
|
||||
|
||||
ipaddr = request.META['REMOTE_ADDR']
|
||||
af = dns.inet.af_for_address(ipaddr)
|
||||
key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6'
|
||||
s[key] = ipaddr
|
||||
|
||||
s.save()
|
||||
with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
|
||||
image_data = f.read()
|
||||
return HttpResponse(image_data, mimetype="image/png")
|
||||
|
Loading…
x
Reference in New Issue
Block a user