flask之返回的响应数据(8)

元组

可以返回一个元组,这样的元组必须是 (response, status, headers) 的形式,且至少包含一个元素。 status 值会覆盖状态代码, headers 可以是一个列表或字典,作为额外的消息标头值。

make_response

resp = make_response()

resp.headers[“sample”] = “value”

resp.status = “404 not found”

原文地址:https://www.cnblogs.com/lirunsheng/p/10996107.html