示例#1
0
def register():
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        # Get Information
        username = form.username.data
        password = form.password.data
        email = form.email.data
        print("\n",username,password,email)
        # Create an instance of User
        user = User(username,email,password)
        # Open and insert into database
        
        try:
            db.session.add(user)
            # Save info into database
            db.session.commit()
        except IntegrityError:
            #return f'username and/or email is not available please re-enter a unique username and email'
            db.session.rollback()
            return redirect(url_for('home'))       
        # Flask Email Sender 
        # msg = Message(f'Thanks for Signing Up! {email}', recipients=[email])
        # msg.body = ('Congrats on signing up! Looking forward to your posts!')
        # msg.html = ('<h1> Welcome to debug_project_app!</h1>' '<p> This will be fun! </p>')
        # mail.send(msg)
        return redirect(url_for('home'))
    return render_template('register.html',form = form)
示例#2
0
def register():
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        # Get Information
        username = form.username.data
        password = form.password.data
        email = form.email.data
        print("\n", username, password, email)
        # Create an instance of User
        user = User(username, email, password)
        # Open and insert into database
        db.session.add(user)
        # Save info into database
        db.session.commit()

        # Flask Email Sender NEEDS API TO WORK
        msg = Message(f'Thanks for Signing Up! {username}', recipients=[email])
        msg.body = ('Congrats on signing up! Looking forward to your posts!')
        msg.html = ('<h1> Welcome to debug_project_app!</h1>'
                    '<p> This will be fun! </p>')
        print(msg)
        mail.send(msg)

        return redirect(url_for('home'))

    return render_template('register.html', form=form)
def register():
    form = UserInfoForm()
    if request.method = 'POST' and form.validate():
        # Get Information
        username = form.username.data
        password = form.password.data
        email = form.email
        print("\n",username,password,email)
        # Create an instance of User
        user = User(username,email,password)
        # Open and insert into database
        db.session.add(user)
        # Save info into database
        db.session.commit()
示例#4
0
def register():
    form = UserInfoForm()
    if request.method == 'POST' and form.validate():
        # Get Information
        username = form.username.data
        password = form.password.data
        email = form.email.data
        print("\n",username,password,email)
        # Create an instance of User
        user = User(username,email,password)
        # Open and insert into database
        db.session.add(user)
        # Save info into database
        db.session.commit()
        return redirect(url_for('login'))

        # Flask Email Sender 
        
    return render_template('register.html',form = form)