2016-06-28 199 views
0

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

+1

你读过http://flask-restful-cn.readthedocs.io/en/0.3.5/quickstart.html? – jonrsharpe

+0

谢谢@jonrsharpe。我错过了那部分。 – Arkady

回答

1

原来我跳过了文档的一部分:

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'} 
相关问题