def index(): # This will serialize our data # `many=True` because there are many ads, ie we expect a list schema = AdSchema(many=True) ads = Ad.select() # get all the ads return schema.dumps(ads) # `schema.dumps` converts the list to JSON