标签:auth turn use port local body dap name lse
import time
user,password=‘abc‘,‘abc123‘
def auth (auth_type):
def out_warpper(funk):
def warpper(*args,**kwargs):
if auth_type==‘local‘:
username =input(‘username‘).strip()
password =input("password").strip()
if username==user and password==password:
print("\033[31;1m welcome to username in the home \033[0m")
res=funk(*args,**kwargs)
return res
else:print("\033[31;1m Invalid username or password\033[0m")
elif auth_type=="ldap":
print("逗你玩呢,没有密码,哈哈哈")
return warpper
return out_warpper
def index():
print("welcome to index page")
@auth(auth_type="local") # home = wrapper()
def home():
print("welcome to home page")
return "from home"
@auth(auth_type="ldap")
def bbs():
print("welcome to bbs page")
index()
print(home()) #wrapper()
bbs()
标签:auth turn use port local body dap name lse
原文地址:https://www.cnblogs.com/nyqxiaoqiang/p/9583648.html