from flask import Flask from flask import (request, session, render_template, redirect, url_for) from flask import Blueprint from werkzeug.security import check_password_hash from . import incr bp = Blueprint('register', __name__, url_prefix='/reg') # Come at the app without a form, you're new. The @bp.route("/reg") @incr.inccnt def gen(): # Give the page. return render_template('regpage.html', count=session['count']) @bp.route("/reg",methods=["POST"]) @incr.inccnt def process(): # Get the creds. userid = request.form['userid'] username = request.form['username'] pwd1 = request.form['pwd1'] pwd2 = request.form['pwd2'] # Check the fields are filled out. Javascript should have done this check, # but we can't depend on that, so we have to check, too. But we don't have # to polite. if userid == '' or username == '' or pwd1 == '' or pwd2 == '': return render_template('regpage.html', count=session['count'], userid=userid, username=username, err='Incomplete form') # Create the account. from . import db err = db.add_user(userid, username, pwd1, pwd2) if err != None: return render_template('regpage.html', count=session['count'], userid=userid, username=username, err=err) return redirect(url_for("gen.count"))