how to build a static website with a constant url that displays dataframe as a table

The file “insurancedetails.html” is stored in an aws bucket with the which can be accessed via this link:

In AWS you can create a static website in bucket or you can just upload an html file and provide links. If you want a domain like (, then there’s a whole other path for that. But the question of creating an html page to show your data via dataframe can be done like I show later. In the end, you can use the data in any application that accepts an html table to create the desired web page design.

dfIns = pd.DataFrame(columns=['S.No', 'Name', 'Amount'])
s = [101,102,103]
n = ['aaa', 'bbb', 'ccc']
a = [12256, 8256, 24525]

dfIns['S.No'] = s
dfIns['Name'] = n
dfIns['Amount'] = a

#create table from dataframe; minimal formatting
table1_html = dfIns.to_html(index=False, border=2)
table1_html = table1_html.replace('<tr>', '<tr align="center">')

# beginning of html page
html_start = """<!DOCTYPE html>
                <html lang="en" dir="ltr">
                    <meta charset="utf-8">
                          table, th, td {
                              border: 1px solid black;
                              height: 22px;
                              padding: 3px;

                          table {
                              border-collapse: collapse;
                              height: 20px;

# closing html tags
html_end = """</body></html>"""

# put it all together
html_conc = html_start + """<caption><b>%s</b></caption>
                             """ % (table1_html) + html_end

#create the file
fn = "insurancedetails.html"
with open(fn, 'w+') as file:

  # Note, I uploaded the file to s3, from local directory, but you can just click in your working directory and see the file that way too.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top