Pandas tuple list returning html string - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Pandas tuple list returning html string (/thread-25208.html) |
Pandas tuple list returning html string - shansaran - Mar-23-2020 Hi I am learning python flask and trying to generate html from python list of tuples using pandas dataframe and to_html method (refer https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.DataFrame.to_html.html) here is my python code output = [('inst1','insttype1','instregion1','instname1',insttime1'),('inst2','insttype2','instregion2','instname2',insttime2')] df = pd.DataFrame(output, columns=['Instance-Id', 'Instance-Type', 'Region', 'Instance-Name', 'Instane-Launch-Time']) htmls = df.to_html(classes="reports") return htmlshere is my python flask and template code @app.route("reports", methods = ['POST']) def reports(): result = t1.getEC2(profilename=request.form['awsprofile']) return render_template('output.html', output=result)<!DOCTYPE html> <html> <head> <title>Reports</title> </head> <body> <h1>Reports Testing</h1><br> {{ output }} </body> </html> When I execute this, the "output" result gets printed as a continous string instead of a table..whereas if I paste directly via https://html5-editor.net/ ..I see the table printed can anyone guide me here what I am doing wrong ? Thanks Shan |