Example #1
0
 def post(self):
     data = request.get_data()
     json_re = json.loads(data)
     phone = json_re['phone']
     password = json_re['password']
     if common.isPhone(phone) or password is None:
         return make_respone(None,400,'用户名或密码设置错误')
     else:
         user =  User(username='******',phone=phone,password=password)
         try:
             db.session.add(user)
             db.session.commit()
             return make_respone(None,200,'注册成功')
         except Exception as e:
             print(e)
             return make_respone(None,600,'注册失败')
Example #2
0
def index():
    # key = '18602736775'
    # token = common.make_token(key,1)
    # print(token)
    # isok = common.certify_token(key,token)
    # print(isok)
    # return 'user index'
    return make_respone()
Example #3
0
 def post(self):
     data = request.get_data()
     json_re = json.loads(data)
     phone = json_re['phone']
     password = json_re['password']
     if common.isPhone(phone) or password is None:
         # return make_respone(data={},message='用户名或密码错误',status=601)
         return make_respone(None,400,'用户名或密码错误')
     else:            
         user  = User.query.filter_by(phone=phone).first()
         if user and user.check_password(password):
             # 根据userid生成token,并返回给前端
             token = common.make_token(str(config.TOKEN_KEY))
             self.respone['id'] = user.id
             self.respone['phone'] = user.phone
             self.respone['token'] = token
             # 在redis中记录token的值
             # RedisCache().set_data(user.id, token)
             # 返回登录成功包
             return make_respone(self.respone, 200, '登录成功')
         else:
             return make_respone(None, 403, '登录失败')
Example #4
0
def print_request_info():
    # print("请求地址:" + str(request.path))
    # print("请求方法:" + str(request.method))
    # print("---请求headers--start--")
    # print(str(request.headers).rstrip())
    # print("---请求headers--end----")
    # print("GET参数:" + str(request.args))
    # print("POST参数:" + str(request.form))
    print(request.remote_addr)

    #可在此处检查jwt等auth_key是否合法,
    #abort(401)
    #然后根据endpoint,检查此api是否有权限,需要自行处理
    #print(["endpoint",connexion.request.url_rule.endpoint])
    #abort(401)
    #也可做ip检查,以阻挡受限制的ip等
    if filter_request(request):
        return make_respone(None, 403, '你被禁了')
Example #5
0
 def post(self):
     self.respone['data'] = [{
         "date": "1997-11-11",
         "name": "林丽丽",
         "address": "吉林省 辽源市 龙山区"
     }, {
         "date": "1987-09-24",
         "name": "文敏",
         "address": "江西省 萍乡市 芦溪县"
     }, {
         "date": "1996-08-08",
         "name": "杨秀兰",
         "address": "黑龙江省 黑河市 五大连池市"
     }, {
         "date": "1978-06-18",
         "name": "魏强",
         "address": "广东省 韶关市 始兴县"
     }, {
         "date": "1977-07-09",
         "name": "石秀兰",
         "address": "江苏省 宿迁市 宿豫区"
     }, {
         "date": "1994-09-20",
         "name": "朱洋",
         "address": "海外 海外 -"
     }, {
         "date": "1980-01-22",
         "name": "傅敏",
         "address": "海外 海外 -"
     }, {
         "date": "1985-10-10",
         "name": "毛明",
         "address": "内蒙古自治区 包头市 九原区"
     }, {
         "date": "1975-09-08",
         "name": "何静",
         "address": "西藏自治区 阿里地区 普兰县"
     }, {
         "date": "1970-06-07",
         "name": "郭秀英",
         "address": "四川省 巴中市 恩阳区"
     }]
     return make_respone(self.respone['data'], 200, '获取数据成功')
Example #6
0
 def post(self):
     datas = db.session.query(swtctop).limit(100).all()
     self.respone['datas'] = [item.to_json() for item in datas]
     return make_respone(self.respone, 200, '获取top address列表成功')
Example #7
0
 def post(self):
     datas = db.session.query(Swtc).group_by('address').limit(10).all()
     self.respone['datas'] = [item.to_json() for item in datas]
     return make_respone(self.respone, 200, '获取address列表成功')
Example #8
0
 def post(self):
     datas = db.session.query(User).all()
     self.respone['datas'] = [item.to_json() for item in datas]
     return make_respone(self.respone, 200, '获取用户列表成功')