1 2 3 4 5 6 7 8 9 10 11 12 | """
simple middlware to block IP addresses via settings variable BLOCKED_IPS
"""
from django.conf import settings
from django import http
class BlockedIpMiddleware(object):
def process_request(self, request):
if request.META['REMOTE_ADDR'] in settings.BLOCKED_IPS:
return http.HttpResponseForbidden('<h1>Forbidden</h1>')
return None
|
More like this
- Firebug Lite Middleware by jfw 3 years, 3 months ago
- User/IP Banning Middleware by justquick 3 years, 9 months ago
- Mobilize your Django site by stevena0 2 years, 10 months ago
- Globs for INTERNAL_IPS by kcarnold 2 years, 10 months ago
- Remove self links middleware by svetlyak 3 years, 10 months ago
Comments