예제 #1
0
def upload_file():
    if request.method == 'POST':
        file = request.files['infile']
        centsPrkWhr = request.form['inelec']
        dollarsPrGal = request.form['ingas']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            uniqname = uuid.uuid4().hex + "." + filename
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], uniqname))

            now = datetime.datetime.now()
            monthNum = now.strftime("%m")

            elecPrice = float(centsPrkWhr) / 100
            gasPrice = float(dollarsPrGal)

            calc = Voltulator(
                os.path.join(app.config['UPLOAD_FOLDER'], uniqname), elecPrice,
                gasPrice, None)
            output = calc.modifyCSV()

            return render_template('table.html', table=output['list'], totalCost=output['outCost'], \
                                   gasCost=str(output['outGas']), percent=str(output['outPercent']))

    return render_template('form.html')
예제 #2
0
def returnExample():
    elecPrice = .107423
    gasPrice = 1.99
    calc = Voltulator(os.path.join("/tmp/", "exampleChargingHistory.csv"), elecPrice, gasPrice, None)
    output = calc.modifyCSV()
    return render_template('table.html', table=output['list'], totalCost=output['outCost'], \
                           gasCost=str(output['outGas']), percent=str(output['outPercent']))
예제 #3
0
def returnExample():
    elecPrice = .10
    gasPrice = 2.65
    calc = Voltulator(
        os.path.join("/data/voltulator/", "exampleChargingHistory.csv"),
        elecPrice, gasPrice, None)
    output = calc.modifyCSV()
    return render_template('table.html', table=output['list'], totalCost=output['outCost'], \
                           gasCost=str(output['outGas']), percent=str(output['outPercent']))
예제 #4
0
def upload_file():
    if request.method == 'POST':
        file = request.files['infile']
        centsPrkWhr = request.form['inelec']
        dollarsPrGal = request.form['ingas']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

            now = datetime.datetime.now()
            monthNum = now.strftime("%m")

            elecPrice = float(centsPrkWhr)/100
            gasPrice = float(dollarsPrGal)

            calc = Voltulator(os.path.join(app.config['UPLOAD_FOLDER'], filename), elecPrice, gasPrice, None)
            output = calc.modifyCSV()

            return render_template('table.html', table=output['list'], totalCost=output['outCost'], \
                                   gasCost=str(output['outGas']), percent=str(output['outPercent']))

    return render_template('form.html')