用户注册接口实现
我们在api_1_0文件中创建了passport.py文件,来写我们的用户注册接口
首先接收参数
from . import api
from flask import request,jsonify
from lghome.response_code import RET
import re
@api.route("/users",methods =["post"])
def register():
"""
注册
:param: 手机号 短信验证码 密码 确认密码
:return: json
"""
# 接受参数,从前端
request_dict = request.get_json()
print(request_dict)
mobile = request.dict.get("mobile")
sms_code = request.dict.get("sms_code")
password = request.dict.get("password")
password2 = request.dict.get("password2")
然后进行简单的验证
# 验证
if not all([mobile,sms_code,password,password2]):