# 4. Response Objects¶

class flask.Response(response=None, status=None, headers=None, mimetype=None, content_type=None, direct_passthrough=False)[source]

The response object that is used by default in Flask. Works like the response object from Werkzeug but is set to have an HTML mimetype by default. Quite often you don’t have to create this object yourself because make_response() will take care of that for you.

If you want to replace the response object used you can subclass this and set response_class to your subclass.

headers

A Headers object representing the response headers.

status

A string with a response status.

status_code

The response status as integer.

data

A descriptor that calls get_data() and set_data(). This should not be used and will eventually get deprecated.

mimetype

The mimetype (content type without charset etc.)

Sets a cookie. The parameters are the same as in the cookie Morsel object in the Python standard library but it accepts unicode data, too.

Parameters: key – the key (name) of the cookie to be set. value – the value of the cookie. max_age – should be a number of seconds, or None (default) if the cookie should last only as long as the client’s browser session. expires – should be a datetime object or UNIX timestamp. domain – if you want to set a cross-domain cookie. For example, domain=".example.com" will set a cookie that is readable by the domain www.example.com, foo.example.com etc. Otherwise, a cookie will only be readable by the domain that set it. path – limits the cookie to a given path, per default it will span the whole domain.