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)
评论列表
文章目录