Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Pandas tuple list returning html string

I am learning python flask and trying to generate html from python list of tuples using pandas dataframe and to_html method

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 htmls

here 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>
<h1>Reports Testing</h1><br>
{{ output }}

When I execute this, the "output" result gets printed as a continous string instead of a table..whereas if I paste directly via ..I see the table printed

can anyone guide me here what I am doing wrong ?


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 80 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  Decoding html to text string PeterPython 1 725 Aug-12-2018, 07:23 PM
Last Post: Larz60+
  How to use BeautifulSoup4 with pandas series type of html data? PrateekG 4 1,562 Apr-26-2018, 07:33 AM
Last Post: PrateekG
  how to edit data frames and convert to a list(pandas, read_html()) ? donvirte 3 1,749 Feb-02-2018, 03:23 PM
Last Post: snippsat
  Pandas reading html returning NaT iFunKtion 1 2,450 Nov-09-2016, 05:31 PM
Last Post: snippsat
  HTML select options from python list adi.6194 4 5,452 Oct-20-2016, 01:31 PM
Last Post: adi.6194

Forum Jump:

Users browsing this thread: 1 Guest(s)