Exemplo n.º 1
0
 def prepare(self):
     remote_ip = self.request.remote_ip
     num = 0
     try:
         num = int(utils.getMem(remote_ip))
     except Exception as e:
         utils.logger.error(e)
     if num == 0:
         utils.setMem(remote_ip, values=str(num + 1), time=24 * 3600)
     elif num < 60:
         utils.setMemReplace(remote_ip, values=str(num + 1))
     else:
         self.write_error(404)
Exemplo n.º 2
0
 def inner(self, *args, **kwargs):
     cookie = self.get_secure_cookie("username")
     isredict = False
     if cookie != None:
         username = cookie.decode()
         data = utils.getMem(username)
         if data != None:
             func(self, *args, **kwargs, data=json.loads(data))
             utils.setMem(key=username, values=data)
         else:
             isredict = True
     else:
         isredict = True
     if isredict == True:
         self.redirect('/')
Exemplo n.º 3
0
 def post(self):
     username = self.get_argument("username", "")
     password = self.get_argument("password", "")
     rs = userdao.getUserByUserPass(username=username, password=password)
     if rs != None:
         self.set_secure_cookie("username", username)
         data = json.dumps({
             "username": username,
             "pasword": password,
             "id": rs.id
         })
         utils.setMem(username, data)
         self.redirect('/index')
     else:
         self.render('login.html', msg="登录失败")