debug ip detection problem

This commit is contained in:
Fabian Faessler 2013-09-29 14:41:47 +02:00
parent 844f08137c
commit fc2e088ba1

View File

@ -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")