Skip to main content
100%

Flask marshal_with Demo

✓ Published0🌍 Public
VVioletVivirand
Last edited Apr 25, 2017
Created on Apr 25, 2017

This example demonstrates how to serialize a pandas DataFrame into JSON using Flask-RESTful’s `marshal_with` decorator. The code defines a `todo_fields` structure that maps DataFrame columns to output keys, including an attribute alias for `col1`. A `JsonContent` resource returns the DataFrame converted to records, and the decorator applies the field mapping to shape the response. The API runs on localhost:8080, showing how `fields.String` and `marshal_with` transform raw pandas data into a clean, structured API payload.

AI-generated description

Similar vizzes