Exemple #1
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        given_password_hash = hashlib.md5(form.password.data).hexdigest()
        redis_key_for_hash = "password:"******"username"] = form.username.data
            session["login time"] = Red.time()
            flash("Hello, {}, you have successfully logged in.".format(
                session["username"]))

            return redirect(url_for('hello'))

        else:
            flash("Invalid login credentials.")
            print "Invalid credentials: username '{}' and password '{}'".format(
                form.username.data, form.password.data)

    elif form.submit.data:
        flash("Incomplete login form.")
        print "Username or password not supplied"

    count = Red.incr('count')
    return render_template('login.html', num_views=count, form=form)
Exemple #2
0
def hello():
    if session.get("username"):
        print "Seconds since login", Red.time()[0] - session["login time"][0]
        num_views = Red.incr('count')
        return 'Hello {}!<br/>{}<br/>{} site views'.format(
            session.get("username"), __file__, num_views)

    else:
        return 'Hello World!\n{}'.format(__file__)
Exemple #3
0
def hello():
    if session.get("username"):
        print "Seconds since login", Red.time()[0] - session["login time"][0]
    count = Red.incr('count')
    all_animals = [
        f[f.find(':') + 1:] for f in Red.scan_iter(match='animal:*')
    ]
    return render_template('index.html',
                           num_views=count,
                           all_animals=all_animals)