diff --git a/nsupdate/api/views.py b/nsupdate/api/views.py index bf7e9e0..a912ca3 100644 --- a/nsupdate/api/views.py +++ b/nsupdate/api/views.py @@ -21,22 +21,15 @@ def MyIpView(request): def DetectIpView(request, secret=None): - s = SessionStore(session_key=secret) - - 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") - out = ipaddr+'\n'+str(request.session)+'\n'+str(s)+'\n'+str(request.session.session_key)+'\n'+str(s.session_key)+'\n'+key - out += '\n'+request.session.get('ipv4','')+' | '+request.session.get('ipv6','') - out += '\n'+s.get('ipv4','')+' | '+s.get('ipv6','') - return HttpResponse(out, mimetype="text/plain") + with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f: + image_data = f.read() + return HttpResponse(image_data, mimetype="image/png") def basic_challenge(realm, content='Authorization Required'): diff --git a/nsupdate/main/templates/main/home.html b/nsupdate/main/templates/main/home.html index f654da6..bf7306a 100644 --- a/nsupdate/main/templates/main/home.html +++ b/nsupdate/main/templates/main/home.html @@ -27,7 +27,8 @@
-
+
+

HeyHo!

{% if request.session.ipv4 and request.session.ipv6 %}

We think this are your IPs:

{% elif request.session.ipv4 or request.session.ipv6 %} @@ -36,10 +37,9 @@ {% if request.session.ipv4 %}

{{request.session.ipv4}}

- {% elif request.session.ipv6 %} -

{{request.session.ipv4}}

- {% else %} -

HeyHo!

+ {% endif %} + {% if request.session.ipv6 %} +

{{request.session.ipv6}}

{% endif %}