Yes, def does define a function. Your functions must be called "get" to handle GET requests and "post" to handle POST requests. Here's a short explanation:
When a HTTP request is received and directed to your request handler (MainPage in this case), the application will call the appropriate function on your request handler. The "appropriate function" is determined by the type of the HTTP request. Most requests are GET requests, which means the client is simply requesting the contents at a particular address. The other, most common, request is POST, which means the client is requesting an address, but it's got some data to deliver first (such as the contents of a form.) So if you type in an address in your browser that goes to the MainPage request handler, the application will attempt to call its "get" function. If you have a form on the page with the attribute method="post", your browser will perform a POST request to the page with the contents of the form. This will call the "post" function. There are also other, less common HTTP requests such as HEAD and PUT, but you barely ever have to worry about those. Regards, Andreas On Jan 27, 2:56 pm, 0815pascal <[email protected]> wrote: > Hello, > > I'm new to google app engine and also new to python. I don't > understand why you have to code it like this: > > class MainPage(webapp.RequestHandler): > def get(self): > > I thought that def would define a function. But if I label it > different then get or post it doesn't work. Can somebody give me a > basic idea? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
