Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return Blank from Python flask API

Tags:

python

flask

api

I have an API that must return just blank and status as 200 OK in case there is no data available

I have tried following things and facing these error

if df.empty:
   return '' , 200

This returns "" in the browser

if df.empty:
   return json.loads('{}'), 200

This return {} in the browser

Send status as 204 (NO CONTENT) makes the previous content to be as it is on the browser

How can i return complete blank with status as 200?

like image 945
Bimal Gangawal Avatar asked Dec 05 '18 11:12

Bimal Gangawal


1 Answers

I have found solution after thoroughly exploring Flask documents

from flask import Response
.....
if df.empty:
   return Response(status = 200)
like image 133
Bimal Gangawal Avatar answered Nov 02 '22 02:11

Bimal Gangawal