Last active
August 29, 2015 14:25
-
-
Save gileno/83956ab8c7ba6c714af5 to your computer and use it in GitHub Desktop.
Middlware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.http import Http404 | |
class MeuMiddleware(object): | |
def process_request(self, request): | |
if request.META["REMOTE_ADDR"] in settings.IPS_PERMITIDOS: | |
pass | |
else: | |
raise Http404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IPS_PERMITIDOS = ( | |
"192.168.0.1", "192.168.0.2" | |
) | |
MIDDLEWARE_CLASSES = ( | |
.... | |
"minha_app.middleware.MeuMiddleware" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment