Flask-DXCaptcha是依赖顶象科技提供的无感验证功能开发的Flask 扩展
Project description
Flask-DXCaptcha是依赖顶象科技提供的无感验证功能开发的Flask 扩展
安装Flask-DXCaptcha
使用 pip 安装
pip install Flask-DXCaptcha
配置
the-config.cfg 文件添加配置项
DX_APP_ID = 'xxx' # APP_ID
DX_APP_SECRECT = 'xxx' # APP_SECRECT
APP_ID和APP_SECRECT需要从 顶象科技官网 获取
跟其他扩展使用的方式类似,简单介绍如下
from flask_dxcaptcha import DXCaptcha
app = Flask(__name__)
app.config.from_pyfile('the-config.cfg')
dxcaptcha = DXCaptcha(app)
或者
from flask import Flask
from flask_dxcaptcha import DXCaptcha
dxcaptcha = DXCaptcha()
...
app = Flask(__name__)
app.config.from_pyfile('the-config.cfg')
dxcaptcha.init_app(app)
如何使用
dxcaptcha.client.setTimeOut(2)
response = dxcaptcha.client.checkToken(v_token)
if response['serverStatus'] == 'SERVER_SUCCESS':
if response['result'] is False:
pass
# token验证失败,业务系统可以直接阻断该次请求或者继续弹验证码
# 具体的实现逻辑
else:
pass
# '提交验证失败,请重新提交'
# 具体的实现逻辑
v_token 值的获取可以参考 官网 文档,下面仅是示例
html
<form>
<div id='c1'></div>
<input id='v_token' name='v_token' />
</form>
javascript
<script src="https://cdn.dingxiang-inc.com/ctu-group/captcha-ui/index.js"></script>
<script type='text/javascript'>
var myCaptcha = _dx.Captcha(document.getElementById('c1'), {
appId: 'appId', // appId
style: 'popup',
width: '100%',
success: function (token) {
document.getElementById('v_token').value = token;
myCaptcha.hide();
}
});
myCaptcha.show();
</script>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-DXCaptcha-1.0.8.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file Flask-DXCaptcha-1.0.8.tar.gz
.
File metadata
- Download URL: Flask-DXCaptcha-1.0.8.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c9df02347fb915a8b56f3b271a7cb486d52c9b70feb6f433150ba1366789357 |
|
MD5 | 59ddc3dceb51e937043066d306d0a3ce |
|
BLAKE2b-256 | 11dae54b65f720a74fc22d17788a8472d2d1b5804e3445ae1590537b4ce63b1c |
File details
Details for the file Flask_DXCaptcha-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: Flask_DXCaptcha-1.0.8-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f00041197d4914b1a77695f1c7c3bd3c372e1ae923d83fdf9f332bae7b2879bd |
|
MD5 | ee83caaaa078c40cb6b12fcf16c7a0e0 |
|
BLAKE2b-256 | fb7a9be2c084038a12e56f8b59a1bb856ed13bd86212ff1f00877623c838c811 |