I know that Response
is what Flask uses by default for http responses. For specific responses format, I usually use make_response
. Are there any specific cases where we have to use flask.Response
instead of flask.make_response
? in other words, does flask.make_response
work in all situations or sometimes flask.Response
is the only or the better alternative? Thanks!
make_response()
gives you a convenience interface, one that will take arguments in more formats than the flask.Response()
object takes.
In addition, make_response()
uses the Flask.response_class
attribute (so app.response_class
) to build the response. The default value for Flask.response_class
is flask.Response
, but you can set this value to a subclass instead.
So you should really always use make_response()
, rather than use flask.Response()
directly, especially if you want to support swapping out what Response
class you actually use for responses.
You may have to use app.response_class
directly if it is a subclass that takes arguments that make_response()
can't supply.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With