import time
user,passwd="LIly","abc123"
def auth(auth_type):
print("auth func:",auth_type)
def outwrapper(func):
def wrapper(*args,**kwargs):
print("wrapper func args:", *args, **kwargs)
if auth_type=="local":
username=input("username:").strip()
password=input("password:").strip()
if username==user and password==passwd :
print(" 33[32:1mUser has passed authentication 33[0m")
res=func(*args,**kwargs) #from home
return res
else:
exit(" 33[31;1mInvalid username or password 33[0m")
elif auth_type=="ldap":
print("搞毛线ldap,不会。。。。")
return wrapper
return outwrapper
def index():
print("welcome to index page")
@auth(auth_type="local")
def home():
print("welcome to home page")
return "from home"
@auth(auth_type="ladp") # home = wrapper()
def bbs():
print("welcome to bbs page")
index()
print(home()) #wrapper
bbs()