Skip to content

Instantly share code, notes, and snippets.

@bencleary
Created May 20, 2020 18:19
Show Gist options
  • Save bencleary/86e8e90b5bc62025f4df13ebb93792e9 to your computer and use it in GitHub Desktop.
Save bencleary/86e8e90b5bc62025f4df13ebb93792e9 to your computer and use it in GitHub Desktop.
Funny middleware for Django that redirects prowling users to a YouTube video
from django.conf import settings
from django.http import HttpResponseRedirect
class AnglerFish:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if any(url in request.path for url in settings.ANGLER_LIGHTS):
return HttpResponseRedirect(settings.ANGLER_TEETH)
else:
response = self.get_response(request)
return response
# Add these to your settings.py
ANGLER_LIGHTS = [
"wp-admin",
"wp-admin.php",
"wp-admin/index.php",
".env",
]
ANGLER_TEETH = "https://youtu.be/DS8HbMFwjGY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment