【发布时间】:2015-08-24 13:54:30
【问题描述】:
我想使用 Tornado 将对象从一个网页('localhost/form')传递到另一个重定向网页('localhost/redirect')。 我的代码 sn-ps 看起来像这样..
class FormHandler (BaseHandler):
def get(self):
redirect_page='localhost/redirect'
some_variable='a variable that can only be generated in FormHandler'
self.write('<button id="Redirect" type="button">Redirect</button><br><script> document.getElementById("Redirect").onclick = function () {location.href ="'redirect_page'";};</script>')
class RedirectHander (BaseHandler):
self.write('The variable passed was'+some_variable)
def make_app():
return Application(
[
url('/', BaseHandler, { "var":"nothing" }, name="root"), # this is for the root! :)
url('/form', FormHandler, { "var":"initialize this!" }, name = "forlorn"),
url('/redirect', RedirectHandler, { "var":"initialize this!" }, name = "forlorn"),
],
# settings:
debug = True,
)
【问题讨论】:
-
问题到底是什么?你有错误吗?
-
如何将变量从 localhost/form 传递到 localhost/redirect?
-
没有错误。就是不知道怎么弄..
标签: python localhost tornado argument-passing