tp2_predictivo / app.py
lkatcheroff's picture
Update app.py
67b517e verified
raw
history blame contribute delete
884 Bytes
from flask import Flask, request, render_template
import pickle
import joblib
import numpy
app = Flask("Modelo Acciones")
@app.route('/', methods=['GET', 'POST'])
def main():
# If a form is submitted
if request.method == "POST":
model = joblib.load("modelo_acciones.pkl")
# Get values through input bars
dias = int(request.form.get("dias"))
try:
dias = int(dias)
except:
dias = 1
output = model.forecast(dias)
prediction = []
i=0
for result in output:
i+=1
prediction.append("Precio de cierre dia " + str(i) +": US$" + str(result))
else:
prediction = ""
return render_template("website.html", outputs = prediction)
# Running the app
if __name__ == '__main__':
app.run(debug = True)