https://gist.github.com/3434633 shows a small application which I send a POST request to - unfortunately this causes the following traceback:
127.0.0.1 - - [23/Aug/2012 19:55:27] "POST /uptime/osiris/ HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/share/pyshared/flask/app.py", line 1518, in call
return self.wsgiapp(environ, start_response)
File "/usr/share/pyshared/flask/app.py", line 1506, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/share/pyshared/flask/app.py", line 1504, in wsgi_app
response = self.full_dispatch_request()
File "/usr/share/pyshared/flask/app.py", line 1265, in full_dispatch_request
response = self.make_response(rv)
File "/usr/share/pyshared/flask/app.py", line 1338, in make_response
File "/usr/share/pyshared/werkzeug/wrappers.py", line 642, in _init
self.status = status
File "/usr/share/pyshared/werkzeug/wrappers.py", line 748, in _set_status
self._status_code = int(self._status.split(None, 1))
IndexError: list index out of range
This is with the following request - curl -d "" http://localhost:5000/uptime/test/ but supplying any post data will cause the same
The issue is with accidentally returning a tuple in my code - however the error doesn't seem like that at all and it was only due to an eagle-eyed person in the IRC channel that I found this one. Could this be made more explicit? (i.e something in the trace to say that this was supposed to be a (content, status) tuple or a single string.
return "You sent " + machine, uptime
If you return a tuple, Flask uses the first argument as response body, and the second as status code.
Since uptime - the second argument of the tuple - is "" and not a valid integer, Werkzeug can't process the response.
Maybe you would have done this:
return "You sent " + machine + uptime
I think this can be closed.
Fair enough, thanks