def send_sms(): phone = request.values.get('phone') if phone: # 产生验证码 num = randint(1000, 9999) # 添加到session session['sms'] = str(num) para = "{'number':'%d'}" % num res = sms.send(phone, para) print(res, type(res)) return jsonify({'code': 1, 'msg': '发送成功'}) return jsonify({"code": 0, 'msg': "电话号码不存在"})
def send_sms(): # if request.method=='POST': phone = request.values.get('phone') # print(phone) # phone='15071348670' if phone: # 产生一个随机验证码 num = randint(1000,9999) # 添加到session中,将来与用户输入比较 session['sms'] = str(num) para = "{'code':'%d'}" % num # 必须是json字符串 res = sms.send(phone, para) print(res, type(res)) return jsonify({'code': 1, 'msg': 'chenggong'}) return jsonify({'code': 0, 'msg': 'no phone'})
def send_sms(): if request.method == 'POST': # 产生验证码 phone = request.values.get("phone") print(phone) num = randint(1000, 9999) # 添加到session session['sms'] = str(num) print(num) para = "{'code':'%d'}" % num res = sms.send(phone, para) print(res) return "已经发送" return "发送失败" # # 短信验证 # @bp.route("/send/",methods=["GET","POST"]) # def send_sms(): # if request.method == "POST": # phone = request.values.get('phone') # print(phone) # if phone: # # 产生验证码 # num = randint(1000,9999) # print(num) # # 添加到session # para = "{'number':'%d'}" % num # session['sms'] = str(num) # # # res = sms.send(phone,para) # # print(res,type(res)) # return "成功" # return "失败" # # # 用户注册 # @bp.route("/register/",methods=['GET','POST']) # def register_user(): # form = RegisterForm() # if request.method == 'POST': # if form.validate_on_submit(): # print(form) # return redirect('/') # return render_template("register.htm",**locals()) # # # 邮件发送 # @bp.route("/mail/") # def send_mail(): # # 创建消息对象 # message = Message(subject="武汉加油", # recipients=['*****@*****.**','*****@*****.**'], # sender=current_app.config.get("MAIL_USERNAME")) # message.body = "中国加油" # 文本邮件 # mail.send(message) # return "发送成功" # @bp.route("/list1/") # @bp.route("/list1/<int:page>/") # def list_user(page=1): # # 搞清楚页码和记录关系:limit (page-1)*10,10 # # 获取分页对象 # pagination = User.query.paginate(page,2) # print(pagination.__dict__) # return render_template("list1.html",**locals())