from flask_table import Table, Col class ItemTable(Table): item_name = Col('Item Name') item_price = Col('Price') data = [ {'item_name': 'Apple', 'item_price': '$1.00'}, {'item_name': 'Banana', 'item_price': '$0.50'}, {'item_name': 'Orange', 'item_price': '$1.25'} ] table = ItemTable(data)
from flask_table import Table, Col class UserData(object): def __init__(self, username, email): self.username = username self.email = email class UserTable(Table): username = Col('Username') email = Col('Email') data = [UserData('John', '[email protected]'), UserData('Jane', '[email protected]'), UserData('Bob', '[email protected]')] table = UserTable(data)In this code, a UserTable is created with two columns, 'Username' and 'Email'. Instead of using a list of dictionaries, the data for the table is provided as a list of UserData objects. The package library used in this code is also flask_table.