问题
I am using Flask-RESTful and would like to handle certain errors by adding a custom HTTP header to my response. Is there a standard Flask or Flask-RESTful way of doing this?
回答1:
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'}
来源:https://stackoverflow.com/questions/38080310/how-to-add-custom-http-response-header-in-flask-restful