Main View
from flask import Flask from flask import request from flask import session from flask import render_template from flask import Blueprint from werkzeug.security import check_password_hash bp = Blueprint('gen', __name__, url_prefix='/gen') # Come at the app without a form, you're new. Expect to have lost # your mind. (May or not be ideal) @bp.route("/init") def init(): # Initialize the state. loggedin = session['loggedin'] = False count = session['count'] = 1 session['hname'] = '' return render_template('counterpage.html', count=1, loggedin=False) from . import incr @bp.route("/login",methods=["POST"]) @incr.inccnt def logo(): # Get the creds. userid = request.form['userid'] pwd = request.form['pwd'] #print("Foo ["+ userid + "] [" + pwd + "]") if userid == '' and pwd == '': return render_template('counterpage.html', count=session['count'], \ loggedin=False) if userid == '' or pwd == '': return render_template('counterpage.html', count=session['count'], \ loggedin=False, err='Incomplete Login') # Verify the login, and generate an appropriate version of the page. from . import db success,text = db.vet_passwd(userid, pwd) if success: session['hname'] = text session['loggedin'] = True return render_template('counterpage.html', count=session['count'], \ loggedin=True, hname=session['hname']) else: return render_template('counterpage.html', count=session['count'], \ loggedin=False, err=text) # This is for plain old next, which can't change login status. @bp.route("/next",methods=["GET"]) @incr.inccnt def count(): # Recover loggedinness. loggedin = session['loggedin'] return render_template('counterpage.html', count=session['count'], \ loggedin=session['loggedin'], \ hname= session['hname']) # Process logout. @bp.route("/logout",methods=["GET"]) @incr.inccnt def out(): # Not logged in now session['loggedin'] = False return render_template('counterpage.html', count=session['count'], \ loggedin=False)