Handling Web Forms Google App Engine
If we want users to be able to post their own greetings, we need a way to process information submitted by the user with a web form. The webapp framework makes processing form data easy.
1 2 3 4 5 6 7 8 9 10 11 | class MainPage(webapp.RequestHandler): def get(self): self.response.out.write(""" <html> <body> <form action="/sign" method="post"> <div><textarea name="content" rows="3" cols="60"></textarea></div> <div><input type="submit" value="Sign Guestbook"></div> </form> </body> </html>""") |
Now lets pull the data out of the post…
1 2 3 4 5 | class Guestbook(webapp.RequestHandler): def post(self): self.response.out.write('<html><body>You wrote:<em>') self.response.out.write(cgi.escape(self.request.get('content'))) self.response.out.write('</em></body></html>') |
By using self.request.get(‘content’) i can get the post data from the field “content”. Easy right?


