2016-06-28 198 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'} 
相關問題