Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
默认情况下,flask send_file 在成功时返回 200 状态。有没有办法改变这种行为?假设我想返回 201。
您始终可以返回一个元组,其中第一个元素是响应对象,在这种情况下是 send_file 返回值,第二个元素是状态码,例如:
return send_file(...), 201
这适用于任何类型的响应(字符串、jsonified 事物等)。