def page(): db.create_all() user_sc = Credentialschema(many=False) data = request.get_json() check_email = data.get('email_address') check_pass = data.get('password') def check(emailid): regexp = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$' if re.search(regexp, emailid): return True else: return False # flagging = check(check_email) # def checkpass(passwd): """ """ if len(passwd) <= 7: return False elif not re.search("[A-Z]", passwd): return False elif not re.search("[0-9]", passwd): return False return True flagging1 = checkpass(check_pass) if Credential.select_user_by_email(check_email): return custom_http_code('Bad resquest', 400) if flagging == False or flagging1 == False: return custom_http_code('Bad request', 400) else: load_data = user_sc.load(data) new_user = Credential(load_data) # Credential.execute_query() db.session.add(new_user) db.session.commit() # result=Credential.query.filter_by(first_name='Jane').first() result = Credential.select_user_by_email(check_email) print(result) data = user_sc.dump(result) print(data) # output=Credential.select_user_by_email(check_email) print("done") return jsonify(data)
def createUser(self, name, email, user, password): self.user = User.User(name, email) self.credential = Credential.Credential('1', user, password) Credential.credentialList.append(self.credential)