简体   繁体   中英

Get response from Flask-RESTPlus in csv

I have created and REST API using Flask-RESTPlus. I am getting response in json and its fine. Now I have a new requirement to specify Response content type as csv or json.

I checked API doc there is nothing mentioned !!

Is it possible to get reponse in csv using Flask-RESTPlus ??

I was able to get output in csv . It took some time though

@api.representation('text/csv') def data_csv(data, code, headers): '''Get result in csv ''' resp = make_response(convert_data(data), code) resp.headers.extend(headers) return resp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM