Example #1
0
def manage():
    if "username" not in session:
        return redirect(url_for('login'))

    # Now let's grab the relevant Redis information (shortened)
    num_req = Red.get('num_requests')
    num_req_dict = {
        key[key.find(':') + 1:]: Red.get(key)
        for key in Red.scan_iter(match="animal-request:*")
    }
    # We add the data from the requests
    req_detail = []
    for key in Red.scan_iter(match="request:*"):
        data = json.loads(Red.get(key))
        data['number'] = key[key.find(':') + 1:]
        req_detail.append(data)

    # Also, management.html has been updated accordingly
    count = Red.incr('count')
    num_active = Red.get('active-requests')
    return render_template('management.html',
                           num_views=count,
                           total=num_req,
                           by_animal=num_req_dict,
                           details=req_detail,
                           total_active=num_active)
Example #2
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)