Mercurial > sat_legacy_website
comparison sat_website/views/whereami.py @ 150:b101828faa0e
split views.py in sub-modules
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 17 Oct 2017 22:16:20 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
149:b1c16cd53b62 | 150:b101828faa0e |
---|---|
1 # -*- coding: utf-8 -*- | |
2 """ | |
3 SàT website: Salut à Toi's presentation website | |
4 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 This file is part of SàT website. | |
7 | |
8 SàT website is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 Foobar is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Affero General Public License | |
19 along with SàT website. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
22 from django.views import View | |
23 from django.http.response import HttpResponse | |
24 | |
25 | |
26 class WhereAmIView(View): | |
27 | |
28 def get(self, request): | |
29 """Return the client IP address""" | |
30 x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') | |
31 if x_forwarded_for: | |
32 ip = x_forwarded_for.split(',')[0] | |
33 else: | |
34 ip = request.META.get('REMOTE_ADDR') | |
35 return HttpResponse(ip) |