In webapp2, I've not been able to make an HTTP DELETE request work correctly. As a workaround, I'm using a different URI with GET, but I'd prefer a more RESTful approach.
With this code, the server log shows the DELETE request as a GET request. What am I missing here?
class TeamPages(webapp2.RequestHandler):
def get(self, team_name):
...
def post(self, team_name):
...
def delete(self, team_name):
key_name = team_name.upper()
Team.delete(key_name)
self.redirect('/teams')
A GET request to /teams/{{ team_name }} responds with a page that includes the following html, but when I submit, it requests the GET method instead of the DELETE method.
<form action="/teams{{ team.team_name }}" method="delete">
<button type="submit">Delete</button>
</form>
Update
Additional info... I'm developing under Google App Engine and I'm using Chrome on a Mac. Here is the request header that shows GET instead of DELETE...
GET /teams/hornets? HTTP/1.1
Host: localhost:9080
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: dev_appserver_login="test@example.com:True:185804764220139124118"
Referer: http://localhost:9080/teams/hornets
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
And here is the response header...
HTTP/1.1 405 Method Not Allowed
allow: DELETE
Cache-Control: no-cache
Content-Length: 187
content-type: text/html; charset=UTF-8
Date: Tue, 10 Jun 2014 21:24:36 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Server: Development/2.0