示例#1
0
	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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
	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)
示例#5
0
文件: blog.py 项目: SeanStar/micolog
 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)