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?
Asked
Active
Viewed 5,748 times
2
-
1Have you read http://flask-restful-cn.readthedocs.io/en/0.3.5/quickstart.html? – jonrsharpe Jun 28 '16 at 15:29
-
Thanks @jonrsharpe. I missed that part. – Arkady Jun 28 '16 at 15:40
1 Answers
9
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'}

Arkady
- 14,305
- 8
- 42
- 46