def get(self): sess=Session(self,timeout=900) num1=random.randint(1,10) num2=random.randint(1,10) code="<span style='font-size:13px;color:red'>%d + %d =</span>"%(num1,num2) sess['code']=num1+num2 sess.save() #self.response.headers['Content-Type'] = "text/html" self.response.out.write(code)
def get(self): sess=Session(self,timeout=900) num1=random.randint(30,50) num2=random.randint(1,10) code="<span style='font-size:12px;color:red'>%d - %d =</span>"%(num1,num2) sess['code']=num1-num2 sess.save() #self.response.headers['Content-Type'] = "text/html" self.response.out.write(code)
def get(self): img = Image() imgdata = img.create() sess = Session(self, timeout=900) if not sess.is_new(): sess.invalidate() sess = Session(self, timeout=900) sess['code'] = img.text sess.save() self.response.headers['Content-Type'] = "image/png" self.response.out.write(imgdata)
def get(self): img = Image() imgdata = img.create() sess=Session(self,timeout=900) if not sess.is_new(): sess.invalidate() sess=Session(self,timeout=900) sess['code']=img.text sess.save() self.response.headers['Content-Type'] = "image/png" self.response.out.write(imgdata)
def get(self): import StringIO code_img, strs = create_validate_code() buf = StringIO.StringIO() code_img.save(buf,'JPEG',quality=70) imgdata = buf.getvalue() sess=Session(self,timeout=900) if not sess.is_new(): sess.invalidate() sess=Session(self,timeout=900) sess['icode']=strs sess.save() self.response.headers['Content-Type'] = "image/jpeg" self.response.out.write(imgdata)