GithubHelp home page GithubHelp logo

mikecunha / visualcaptcha-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from desirepath41/visualcaptcha-python

0.0 1.0 0.0 654 KB

Python package for visualCaptcha's backend service

License: MIT License

Python 100.00%

visualcaptcha-python's Introduction

Build Status Coverage Status Codacy Code Climate

visualCaptcha-python

Python package for visualCaptcha's backend service

Installation with PIP

You need Python installed with pip.

pip install visualcaptcha

Run tests

Run next command to run unit tests:

python test.py

Usage

Initialization

On initialization visualCaptcha function requires a Session session object as first argument:

from visualcaptcha import Session, Captcha
visualCaptcha = Captcha( Session(session) )
# Optional arguments: visualCaptcha = Captcha( Session(session, namespace), assetsPath, defaultImages, defaultAudios )

Where:

  • session is a required shared session object, where correct and option values are stored for later verification in the backend
  • namespace is an optional argument. Defaults to 'visualcaptcha' and you can use it to use more than one visualCaptcha in the same page
  • assetsPath is an optional argument. Defaults to the full path of './assets'.
  • defaultImages is an optional parameter. Defaults to the array inside of ./assets/images.json. The path key is relative to ./assets/images/
  • defaultAudios is an optional parameter. Defaults to the array inside of ./assets/audios.json. The path key is relative to ./assets/audios/

visualCaptcha.Captcha attributes

  • session, Session object — An object that will have a reference for the session object. It will have the following keys inside visualCaptcha key: images, audios, validImageOption, and validAudioOption.

  • imageOptions, list — All the image options. These can be easily overwritten with defaultImages when initializing Captcha. By default, they're populated using the ./assets/images.json file.

  • audioOptions, list — All the audio options. These can be easily overwritten with defaultAudios when initializing Captcha. By default, they're populated using the ./assets/audios.json file.

visualCaptcha.Captcha methods

  • generate: ( self, numberOfOptions = 5 ) — Generate a new valid visualCaptcha front-end data. numberOfOptions — is an optional parameter for the number of generated images, defaults to 5.
  • getFrontendData: ( self ) — Get data to be used by the frontend.
  • getValidImageOption: ( self ) — Get the current validImageOption.
  • getValidAudioOption: ( self ) — Get the current validAudioOption.
  • validateImage: ( self, sentOption ) — Validate the sent image value (sentOption) with the validImageOption.
  • validateAudio: ( self, sentOption ) — Validate the sent audio value (sentOption) with the validAudioOption.
  • getImageOptions: ( self ) — Return generated image options.
  • getImageOptionAtIndex: ( self, index ) — Return generated image option at given index.
  • getAudioOption: ( self ) — Alias for getValidAudioOption.
  • getAllImageOptions: ( self ) — Return all the image options.
  • getAllAudioOptions: ( self ) — Return all the audio options.
  • streamAudio: ( self, headers, fileType = 'mp3' ) — Stream audio file. Parameters:
    • headers is a list with the HTTP headers to be set;
    • fileType is the audio filetype, defaults to 'mp3', and it can also be 'ogg'.
  • streamImage: ( self, headers, index, isRetina = False ) — Stream image file at given index for generated options. Parameters:
    • headers is a list with the HTTP headers to be set;
    • index is index of the image in the session images list to receive;
    • isRetina, boolean, deciding if the normal or retina image should be streamed, defaults to False.

Pushing to PyPi

$ python setup.py sdist upload

License

View the LICENSE file.

visualcaptcha-python's People

Watchers

Mike Cunha 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.