在webapp2中,我无法使HTTP请求正确工作。作为一种解决办法,我使用的是与GET不同的URI,但我更喜欢使用更多的RESTful方法。
使用此代码,服务器日志将删除请求显示为GET请求。我在这里错过了什么?
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')对/teams/{{ team_name }的GET请求使用包含以下html的页面进行响应,但当我提交时,它将请求GET方法而不是DELETE方法。
<form action="/teams{{ team.team_name }}" method="delete">
<button type="submit">Delete</button>
</form>更新
更多信息..。我是在Google下开发的,我在Mac上使用Chrome。以下是显示GET而不是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这是响应头..。
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发布于 2014-06-11 00:42:22
https://stackoverflow.com/questions/24150161
复制相似问题