Skip to main content
 首页 » 编程设计

python之使用 http put 方法的 webapp2 有什么好的工作示例吗

2025年05月04日27jiqing9006

我想使用 HTTP PUT 方法,将数据发送到我的谷歌应用引擎应用程序,有什么好的例子吗?我无法从谷歌中找到任何内容。

我下面的例子也不起作用。

import webapp2 
 
class MainHandler(webapp2.RequestHandler): 
    def put(self): 
        self.response.write('test put') 
 
app = webapp2.WSGIApplication([ 
    (r'/test/(.*)', MainHandler) 
], debug=True) 

我得到了这个错误。

TypeError: put() takes exactly 1 argument (2 given) 

请您参考如下方法:

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

(r'/test/(.*)', MainHandler) 

(.*) 在 /test/ 之后传递 put 方法来访问此 urlpath。
像这样更新你的处理程序:

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