Can't get POST parameters

荒凉一梦 提交于 2019-12-06 03:46:58

Try removing the enctype="text/plain" attribute from the form, and then use self.request.POST.get('eMail') and self.request.POST.get('pwd').

Edit: The reason why removing enctype="text/plain" works is because you want the enctype to be "text/html" (which is the default) in order for webapp2 to read the form as an html form. When it is just set to "text/plain", the form's output is contained in the body of the request as just text, which is what you saw when you printed out the request. If you use "text/plain", then you could access the form's output as a string by using:

form_string = str(self.request.body)

and then you could parse that string to get the key-value pairs. As you're already aware though, it is easier just to set the enctype to html to get the standard http-form functionality.

I couldn't specifically find enctype information in the documentation, but if you have other questions about the request object I suggest reading the Webob Documentation for a request object. Webapp2 uses Webob requests, so that documentation is the place to go to understand your request obejct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!