def post(self): try: body = request.get_json() user = User(**body) user.validate() user.hash_password() user.save() return jsonify(user) except NotUniqueError as e: return "User already exists!", 409 except ValidationError as e: return e.to_dict(), 422
def post(self): body = request.get_json() if body is not None: try: user = User(**body) user.validate() user.hash_password() user.save() except NotUniqueError as nue: return {"message": "Email alreay Exists"}, 419 except ValidationError as ve: return {"message": str(ve.errors)}, 420 except FieldDoesNotExist as fdne: return {"message": fdne.args[0]}, 418 except Exception as e: return {"message": "something went wrong"}, 400 return {"message": "Signup Successful"}, 200 else: return { "message": "body should be non empty, valid json object" }, 422