def register(): name = get_or_400(request.get_json(), 'name') user = db.session.query(User).filter(User.name==name).first() if user is not None: return make_api_resp(status_code=400, msg='user exists') password = get_or_400(request.get_json(), 'password') password_hash = bcrypt.generate_password_hash(password) user = User(name=name, password=password_hash) db.session.add(user) db.session.commit() return make_api_resp({'user_id':user.id})
def register(): name = get_or_400(request.get_json(), 'name') user = db.session.query(User).filter(User.name == name).first() if user is not None: return make_api_resp(status_code=400, msg='user exists') password = get_or_400(request.get_json(), 'password') password_hash = bcrypt.generate_password_hash(password) user = User(name=name, password=password_hash) db.session.add(user) db.session.commit() return make_api_resp({'user_id': user.id})
def get_user(): user_id = get_user_id_or_401() user = db.session.query(User).get(user_id) return make_api_resp({'user': {'id': user_id, 'name': user.name}})
def default_error_handler(error): return make_api_resp(status_code=error.code, msg=error.name)
def index(): i = get_int_arg_or_400('i') s = get_arg_or_400('s') d = request.args.get('d', 'ddd') return make_api_resp({'i': i, 's': s, 'd': d})
def get_user(): user_id = get_user_id_or_401() user = db.session.query(User).get(user_id) return make_api_resp( {'user':{'id':user_id, 'name':user.name}} )
def index(): i = get_int_arg_or_400('i') s = get_arg_or_400('s') d = request.args.get('d', 'ddd') return make_api_resp({'i':i, 's':s, 'd':d})