Reputation: 5724
I'm getting started learning Werkzeug. I see how to create a simple response:
def __call__(self, environ, start_response):
response = Response('hi there!')
return response(environ, start_response)
What's the easiest way to construct an error response? That is, other than the message content itself! Is there some way to set the response to indicate that it is an error?
Upvotes: 0
Views: 385
Reputation: 931
From the docs:
def application(environ, start_response):
path = environ.get('PATH_INFO') or '/'
if path == '/':
response = index()
else:
response = Response('Not Found', status=404)
return response(environ, start_response)
When constructing the Response object, you can specify a HTTP code to indicate an error back to the browser/user.
Upvotes: 1