Skip to content

Instantly share code, notes, and snippets.

@gileno
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gileno/83956ab8c7ba6c714af5 to your computer and use it in GitHub Desktop.
Save gileno/83956ab8c7ba6c714af5 to your computer and use it in GitHub Desktop.
Middlware
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
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