This question is not a duplicate of Passing HTML to template using Flask/Jinja2. It deals with dataframes and is specific to a layout. Please read it carefully.
I have created a file load interface for uploading training and test data. Now I want, on the right portion of the page just opposite to the corresponding button, that data.head()
should be printed, to get an idea of the structure of the data. This should happen after the /upload
route is called.
I am aware of the df.to_html()
option, but I'm not able to think where to incorporate it in the code.
Code used is:
from flask import Flask, render_template, request
from werkzeug import secure_filename
app = Flask(__name__)
@app.route('/upload', endpoint = 'upload_file1')
def upload_file1():
return render_template('view.html')
@app.route('/upload', endpoint = 'upload_file3')
def upload_file3():
return render_template('view.html')
@app.route('/uploader', methods = ['GET', 'POST'], endpoint= 'upload_file2')
def upload_file2():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return 'file uploaded successfully'
if __name__ == '__main__':
app.run(debug = True, use_reloader=False)