コード例 #1
0
def index():
    # This will serialize our data
    # `many=True` because there are many works, ie we expect a list
    schema = WorkSchema(many=True)
    works = Work.select()  # get all the works
    return schema.dumps(works)  # `schema.dumps` converts the list to JSON
コード例 #2
0
def index():
    schema = WorkSchema(many=True)
    works = Work.select()
    return schema.dumps(works)