From 23674cc0612c8355d372d652588d259cb66b5696 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Feb 2019 15:25:15 +0100 Subject: [PATCH] Update view, remove debug printing --- no_ipv4_here/templates/no_ipv4_here/index.html | 2 +- no_ipv4_here/views.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/no_ipv4_here/templates/no_ipv4_here/index.html b/no_ipv4_here/templates/no_ipv4_here/index.html index 31f6372..37a755b 100644 --- a/no_ipv4_here/templates/no_ipv4_here/index.html +++ b/no_ipv4_here/templates/no_ipv4_here/index.html @@ -50,7 +50,7 @@

You have reached the end of the IPv4 Internet. - {% if domain != "" %} + {% if back_to_url != "" %}
The site {{ domain }} is not reachable by IPv4. To access diff --git a/no_ipv4_here/views.py b/no_ipv4_here/views.py index f8390c5..feb48e2 100644 --- a/no_ipv4_here/views.py +++ b/no_ipv4_here/views.py @@ -10,17 +10,19 @@ class IndexView(TemplateView): template_name = 'no_ipv4_here/index.html' def get_context_data(self, **kwargs): - import pprint - pprint.pprint(self.request.META) context = super(IndexView, self).get_context_data(**kwargs) back_to_url = "" + if "back_to" in self.request.GET: back_to_url = self.request.GET["back_to"] elif 'HTTP_HOST' in self.request.META: # Exclude ourselves - if not re.match("^no-ipv4-here.ungleich.ch", self.request.META['HTTP_HOST']): + if not re.match("^(no-ipv4-here.ungleich.ch|localhost)", self.request.META['HTTP_HOST']): back_to_url = "http://{}".format(self.request.META['HTTP_HOST']) + + context['back_to_url'] = back_to_url if back_to_url != "": context['domain'] = (urlsplit(back_to_url)).netloc + return context