예제 #1
0
파일: app.py 프로젝트: dexhrestha/ecom
def signup():
    if session.get('username'):
        print(session.get('username'))
        return redirect(url_for('home'))

    form = SignupForm()

    if request.method == 'GET':
        return render_template('signup.html', form=form)

    if request.method == 'POST':
        fname = form.fname.data.strip()
        lname = form.lname.data.strip()
        email = form.email.data.strip()
        password = form.password.data.strip()
        #validate form
        if form.validate_on_submit():
            User.create(fname=fname,
                        lname=lname,
                        email=email,
                        password=password)
            return redirect(url_for('login'))
        print(form.errors)
        return render_template('signup.html', form=form)