[英]How to add custom HTTP response header in Flask-RESTful?
I am using Flask-RESTful and would like to handle certain errors by adding a custom HTTP header to my response. 我正在使用Flask-RESTful,并想通过在响应中添加自定义HTTP标头来处理某些错误。 Is there a standard Flask or Flask-RESTful way of doing this?
有标准的Flask或Flask-RESTful方法吗?
Turns out I skipped over that part of the docs: 原来我跳过了文档的那一部分:
class Todo3(Resource):
def get(self):
# Set the response code to 201 and return custom headers
return {'task': 'Hello world'}, 201, {'Etag': 'some-opaque-string'}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.