When using webapp from Google App Engine, how can I distinguish POST and GET? Which one gets priority and how can I seprate them? A piece of code below shows the way to obtain a POST/GET field value:
class AddWordHandler(webapp.RequestHandler):
def post(self):
theWord = str( self.request.get('theWord', default_value="no") )
I’d like to ask more: How to handle GET, POST and Cookies smoothly and transparently without writing your own parser?
On each request, the webapp framework calls the method named after the HTTP method. Thus, GET requests call ‘get()’, POST requests call ‘post()’, and so on.
To retrieve submitted values, you can use self.request.get(), which works for both post data and query string data, or self.request.GET and self.request.POST which are multidicts for query string data and posted data, respectively.
The webapp framework’s request object is based on the webob one, so for more information on this and how to handle cookies, see the webob documentation.