ven*_*enj 7 python google-app-engine
在GAE Python中,我可以使用
class MyRequestHandler(webapp.RequestHandler):
def get(self):
pass #Do Something...
def post(self):
pass #Do Something...
Run Code Online (Sandbox Code Playgroud)
处理GET和POST请求.但是我如何处理DELETE和PUT?我在API文档中看到了delete()和put(),但我不知道如何编写表单来模拟DELETE和PUT.
我知道在Rails中,我可以使用post方法在表单中使用隐藏字段来模拟这样的请求:
<input type="hidden" name="_method" value="delete" />
Run Code Online (Sandbox Code Playgroud)
和Rails自动处理脏工作.
在GAE python中有没有类似的方法呢?
我在谷歌搜索过这个,但没有运气.
谢谢.
您可以使用接受get,post,delete和put等所有方法的请求方法.然后,您可以相应地检查它的请求类型.
检查一下:
http://gdata-python-client.googlecode.com/svn/trunk/pydocs/gdata.urlfetch.html
<form method="post" action="">
<input type="hidden" name="_method" value="put" />
<input type="text" name="name" value="" />
<input type="submit" value="Save" />
</form>
def post(self):
method= self.request.get("_method")
if method == 'put':
#call put() function as required
Run Code Online (Sandbox Code Playgroud)
你可以通过这个以及put规范.
| 归档时间: |
|
| 查看次数: |
1966 次 |
| 最近记录: |