0
我有兩個處理程序。在第一個(FooHandler)中,我在GET方法中顯示一個表單,並獲取該字段的值POST方法。一旦獲得該值,我想通過URI將它傳遞給另一個處理程序。然後BarHandler接收它並能夠進行查詢。龍捲風 - 從URL中獲取變量
class FooHandler(tornado.web.RequestHandler):
def get(self):
self.render("templates/fooForm.html")
def post(self):
var1 = self.get_argument('var1') #number
self.redirect('/query/{}'.format(var1))
class BarHandler(tornado.web.RequestHandler):
def get(self, var1):
q = Query....
def main():
io_loop = tornado.ioloop.IOLoop.instance()
connect("test", host="localhost", port=27017, io_loop=io_loop)
app = tornado.web.Application(
[
(r"/", FooHandler),
(r"/query/\d+", BarHandler)
], debug = True,
)
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
if __name__ == "__main__":
main()
我得到這個錯誤:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1443, in _execute
result = method(*self.path_args, **self.path_kwargs)
TypeError: get() takes exactly 2 arguments (1 given)
我不知道如何從FooHandler通過VAR1,趕上它BarHandler。任何建議?