使用http put方法为webapp2做任何好的工作示例?

Dan*_*ong 1 python google-app-engine

我想使用HTTP PUT方法,将数据发送到我的谷歌应用引擎应用程序,任何好的例子?我从谷歌找不到任何东西.

而我的以下示例也无效.

import webapp2

class MainHandler(webapp2.RequestHandler):
    def put(self):
        self.response.write('test put')

app = webapp2.WSGIApplication([
    (r'/test/(.*)', MainHandler)
], debug=True)
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误.

TypeError: put() takes exactly 1 argument (2 given)
Run Code Online (Sandbox Code Playgroud)

asc*_*d00 5

你正在传递put参数映射它像这样:

(r'/test/(.*)', MainHandler)
Run Code Online (Sandbox Code Playgroud)

(.*)通行证无论你使用后访问此urlpath的put方法/test/.
像这样更新你的处理程序:

class MainHandler(webapp2.RequestHandler):
    def put(self, myarg):
        self.response.write('test put, myarg is %s' %myarg)
Run Code Online (Sandbox Code Playgroud)