Created
October 1, 2016 11:45
-
-
Save justanr/23e50636c90203626bec3bcb92010cbc to your computer and use it in GitHub Desktop.
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 datetime import datetime | |
SUNDAY = 6 | |
class UncleVernonMiddleware(object): | |
def __init__(self, app): | |
self.app = app | |
def __call__(self, environ, start_response): | |
if environ['REQUEST_METHOD'].lower() == 'post' and datetime.now().weekday() == SUNDAY: | |
start_response('405 METHOD NOT ALLOWED', []) | |
return ['No Post On Sundays'] | |
return self.app(environ, start_response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment