【发布时间】:2011-03-22 12:31:07
【问题描述】:
表单发布后不显示页面内容,但直接查看页面时显示。我有一段 Python App Engine 代码试图指向一个新页面并显示一段以编程方式定义的(即在代码中,而不是在 html 中)文本。但是,按下表单的提交按钮,我得到一个空白页,没有错误消息。
我一直在使用 Google App 引擎代码示例。该表单只需要一些选项,但我什至没有从中收集任何内容,应该转到新页面,但它没有,我无法找出它可能出错的地方。
我有
class MainPage(webapp.RequestHandler):
def get(self):
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
和
class Confirm(webapp.RequestHandler):
def post(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('You have confirmed!')
application = webapp.WSGIApplication(
[('/', MainPage),
('/confirm', Confirm)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
在 HTML 中:index.html
<html>
<body>
<form action="/confirm" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Submit"></div>
</form>
</body>
</html>
我想知道为什么如果我提交表单,我没有得到你已经确认!消息,但如果我去 /confirm 我会这样做。谢谢。
【问题讨论】:
-
您的 MainPage 处理程序似乎有缩进问题。这是在这里编辑时缩进的问题,还是你有这样的问题?
-
缩进问题只是在 S.O.
-
为你解决了缩进问题