Attempting to develop a python web service on the Google App Engine that will handle data posted from an HTML form. Can someone please advise what I'm doing wrong? All files residing in the same directory on the desktop \helloworld.
OS: Win 7 x64 Python 2.7 Google App Engine (Local)
helloworld.py
import webapp2
import logging
import cgi
class MainPage(webapp2.RequestHandler):
def post(self):
self.response.headers['Content-Type'] = 'text/plain'
form = cgi.FieldStorage()
if "name" not in form:
self.response.write('Name not in form')
else:
self.response.write(form["name"].value)
app = webapp2.WSGIApplication([('/', MainPage)],debug=False)
page.html
<html>
<body>
<form action="http://localhost:8080" method="post">
Name: <input type="text" name="name"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
Using a browser (Chrome) viewing the page.html, I input a text into the field and press submit, I expect to see the text being displayed in the browser, but I get "Name not in form". It works if I change the HTML form method to get and the python function to def get(self), but I would like to use the post method. Any help with explanation would be appreciated.