def code_verify(request):
image_str = request.forms.get("code")
typ = int(request.forms.get('type'))
filename = os.path.join(
curpath,
'temp',
'%s.png'%(
md5.md5(
str(time.time()) + str(random.random())
).hexdigest()
)
)
with open(filename, 'wb') as f:
f.write(image_str)
img = Image.open(filename)
exec '''from main import main_%s'''%(typ)
exec '''code = main_%s.verify(img, code_template_dic[typ])'''%(typ)
#exec '''code = main_%s.verify(img)'''%(typ)
if hasattr(img, 'close'):
img.close()
try:
print os.remove(filename)
except Exception as e:
print u"?????? %s"%e
return code
评论列表
文章目录