示例#1
0
    def get(self):
        service = tools.obtain_captcha_service()
        captcha_random = service.random()
        captcha_image = service.image()
        hosted_files = self._count_hosted_files()

        self.render("uploadform.html",
            hosted_files=hosted_files,
            captcha_random=captcha_random,
            captcha_image=captcha_image)
示例#2
0
文件: main.py 项目: barneyzhu/uploadr
    def get(self):
        service = tools.obtain_captcha_service()
        captcha_random = service.random()
        captcha_image = service.image()
        hosted_files = self._count_hosted_files()

        self.render("uploadform.html",
            hosted_files=hosted_files, 
            captcha_random=captcha_random,
            captcha_image=captcha_image)
示例#3
0
    def _validate_captcha(self):
       if tools.devel_env():
           return True

       service = tools.obtain_captcha_service()
       random = self.get_argument("captcha_random", None)
       password = self.get_argument("captcha_password", None)
       if random is None or password is None:
           return False

       random = tornado.escape.xhtml_escape(random)
       password = tornado.escape.xhtml_escape(password)

       logging.debug("Validating captcha (Random: %s, Password: %s)" %
            (random, password))

       return service.validate(random) and service.verify(password)