views.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:otp_demo_server 作者: ownpush 项目源码 文件源码
def home():
    form = SendToDeviceForm(request.form)

    if form.validate_on_submit():
        device = PushDevice.query.filter_by(device_uid=form.device_uid.data).first()

        if device is None:
            flash('Device not found (please check id)', "danger")
        else:
            otp = binascii.b2a_hex(os.urandom(4)).decode()
            push_status_txt = sendpush(device.push_id, otp)
            push_json = json.loads(push_status_txt)

            if "status" in push_json:
                if push_json['status'] == "OK":
                    flash("One Time Password Sent To Device", "success")
                else:
                    flash("Could Not Communicate With Device ( " + push_status_txt + " )", "danger")

    return render_template('main/home.html', form=form)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号