Created
March 22, 2016 02:40
-
-
Save hahastudio/426a750fb4c7a4beb210 to your computer and use it in GitHub Desktop.
a Flask decorator in https://www.v2ex.com/t/265346
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
def required(argName): | |
def decorator(f): | |
def wrapper(*args, **kwarg): | |
if request.args.get(argName): | |
return f(*args, **kwarg) | |
else: | |
abort() | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment