Example #1
0
def process():
    if request.method == 'POST':
        file = request.files['file']
        if file and allowed_file(file.filename):
            try:
                data = csv_read(file.read())
                print unicode(data)
                return render_template("graph.html", data=unicode(data), tip=tipper())
            except:
                return "Invalid PGE GreenButton file"
    return render_template("index.html")
Example #2
0
def process2():
    global buff
    if request.method == "POST":
        print "posting data"
        time = request.form["time"]
        demand = float(request.form["demand"])
        buff.append({"kWh":demand, "time":time})
        if len(buff) > BUFF_SIZE:
            buff.pop(0)
    print list(buff)
    data = {"readings":list(buff)}
    jsdat = json.dumps(data)
    return render_template("livegraph.html", data=unicode(jsdat), tip=tipper())