Пример #1
0
def upload_file():
    print("Uploading CSV... ")
    error = ''
    #    os.remove('Output.zip')
    try:
        if request.method == 'POST':
            f = request.files['file']
            f.save(secure_filename(f.filename))
            df = read_file(f.filename)
            df_out = model_run(df)
            print("Out from model_run")
            #df.to_csv('predictoutput.zip',sep=',',index=False)
            #os.remove(f.filename)
            #return render_template("view.html",tables=[df1.to_html()], titles = ['Predicted O/P'])
            return render_template(
                "formout.html",
                tables=[df, df_out],
                titles=['Inputs Given', 'O/p Predicted by different Models'])
            #return render_template("view.html",name='Predicted O/P', tables=[df_summ.to_html(),df1.to_html()], titles = ['Error Metrics','Predicted O/P'])
            #jsonfiles = json.loads(df.head().to_json(orient='records'))
            #return render_template('view.html', ctrsuccess=jsonfiles)
            #tables=[df.to_html(classes='dataframe')], titles = ['na', 'Predicted O/P'])
            #flash("File uploaded")
        error = "File Not uploaded"
        return render_template("dashboard.html", error=error)
    except Exception as e:
        #flash(e)
        print(e)
        return render_template("dashboard.html", error=error)
Пример #2
0
def upload_file():
    print("upload hiiiiiiiiiii")
    error = ''
    try:
        if request.method == 'POST':
            txt = request.form['txt']
            df = model_run(txt, app.root_path)
            return render_template("view.html",
                                   table=df.to_html(),
                                   titles='tweets O/P')
        error = "error getting request"
        return render_template("dashboard.html", error=error)
    except Exception as e:
        flash(e)
        print(e)
        return render_template("dashboard.html", error=error)