【文件属性】:
文件名称:Django验证码库DjangoCaptcha.zip
文件大小:963KB
文件格式:ZIP
更新时间:2022-08-06 05:27:25
开源项目
在django中生成英文单词验证码,提供验证码图片生成,检查验证码等功能 原用于pythoner.net的验证码,现整理出来打包发布到pypi.
新特性
新增数字验证码模式
字体尺寸根据图片长宽自适应
Usage
Install
pip install DjangoCaptcha
or
easy_install DjangoCaptcha
Display(views.py)
from DjangoCaptcha import Captcha
def code(request):
ca = Captcha(request)
ca.words = ['hello','world','helloworld']
ca.type = 'number'
return ca.display()
Check user input(views.py)
from DjangoCaptcha import Captcha
def index(request):
_code = request.GET.get('code') or ''
if not _code:
return render('index.html',locals())
ca = Captcha(request)
if ca.check(_code):
return HttpResponse('验证成功')
else:
return HttpResponse('验证失败')
Custom
width of image
ca.img_width = 150
height of image
ca.img_height = 30
type fo code ('number'/'word')
ca.type = 'number'
Rely on
PIL
More
http://pythoner.net
【文件预览】:
DjangoCaptcha-master
----DjangoCaptcha()
--------words.list(146B)
--------Menlo.ttc(2.07MB)
--------__init__.py(6KB)
--------timesbi.ttf(234KB)
----test.py(0B)
----__init__.py(0B)
----demo()
--------settings.py(5KB)
--------DjangoCaptcha(16B)
--------urls.py(258B)
--------manage.py(242B)
--------requirements.txt(23B)
--------__init__.py(0B)
--------env.sh(278B)
--------setenv.sh(279B)
--------main()
--------templates()
----.travis.yml(115B)
----LICENSE(563B)
----setup.py(463B)
----README.md(1KB)
----.gitignore(2KB)