Python 如何在Flask RESTful中添加自定义HTTP响应头?

Python 如何在Flask RESTful中添加自定义HTTP响应头?,python,flask,flask-restful,Python,Flask,Flask Restful,我正在使用Flask RESTful,希望通过向响应中添加自定义HTTP头来处理某些错误。有没有一种标准的烧瓶或烧瓶RESTful方法可以做到这一点?结果我跳过了文档的这一部分: class Todo3(Resource): def get(self): # Set the response code to 201 and return custom headers return {'task': 'Hello world'}, 201, {'Etag':

我正在使用Flask RESTful,希望通过向响应中添加自定义HTTP头来处理某些错误。有没有一种标准的烧瓶或烧瓶RESTful方法可以做到这一点?

结果我跳过了文档的这一部分:

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'}

结果我跳过了文档的这一部分:

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'}

你读了吗?谢谢@jornsharpe。我错过了那部分。你读了吗?谢谢@jornsharpe。我错过了那部分。