从下面的代码中可以看出,我有一个GET
for 注册,它将其工作委托给POST
.
class RegistrationHandler(tornado.web.RequestHandler):
def get(self):
s = """
<h1>Register</h1>
<form method="post" action="/register">
<div>
<label>User</label>
<input name="user_name" value="test@test.com"/>
</div>
<div>
<label>password</label>
<input name="password" type="password"/>
</div>
<div>
<input type="submit" value="submit"/>
</div>
</form>
"""
self.write(s)
@log_exception()
def post(self):
user_name = self.request.arguments['user_name']
password = self.request.arguments['password']
log.debug('Registering user with credentials %r' % (user_name, password))
with sa_session() as db_session:
User.register(user_name, password, db_session)
当我从我的网络浏览器访问 URL 时,我得到一个注册表单,提交后我得到“403:禁止”。
控制台日志:
2012-10-15 11:27:42,482 - __main__ - DEBUG - Starting server on port 8080
2012-10-15 11:27:49,377 - root - INFO - 304 GET /register (127.0.0.1) 0.78ms
2012-10-15 11:27:53,143 - root - WARNING - 403 POST /register (127.0.0.1): '_xsrf' argument missing from POST
2012-10-15 11:27:53,144 - root - WARNING - 403 POST /register (127.0.0.1) 1.05ms
这个错误是什么意思,我该如何纠正?谢谢。