Created
May 20, 2020 18:19
-
-
Save bencleary/86e8e90b5bc62025f4df13ebb93792e9 to your computer and use it in GitHub Desktop.
Funny middleware for Django that redirects prowling users to a YouTube video
This file contains hidden or 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 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 |
This file contains hidden or 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
# 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