Skip to content

Instantly share code, notes, and snippets.

@justanr
Created October 1, 2016 11:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justanr/23e50636c90203626bec3bcb92010cbc to your computer and use it in GitHub Desktop.
Save justanr/23e50636c90203626bec3bcb92010cbc to your computer and use it in GitHub Desktop.
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