GithubHelp home page GithubHelp logo

djangocaptcha's Introduction

DjangoCaptcha

image PyPI version

介绍

在django中生成英文单词验证码,提供验证码图片生成,检查验证码等功能 原用于pythoner.net的验证码,现整理出来打包发布到pypi.

新特性

  • 新增数字验证码模式
  • 字体尺寸根据图片长宽自适应

Start

####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 = 'word'
    return ca.display()

or

from DjangoCaptcha import Captcha
def code(request):
    figures         = [2,3,4,5,6,7,8,9]
    ca              = Captcha(request)
    ca.words        = [''.join([str(random.sample(figures,1)[0]) for i in range(0,4)])]
    ca.type         = 'word'
    ca.img_width    = 100
    ca.img_height   = 30
    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('验证失败')

Config

width of image

ca.img_width = 150

height of image

ca.img_height = 30

type fo code ('number'/'word')

ca.type = 'number'

More

djangocaptcha's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.