The WebpyApplication works in the same way as the RegexApplication but calls the callbacks in a different way:
from colubrid import WebpyApplication, HttpResponse, execute
class HelloWorld(object):
def GET(self, name):
name = name or 'world'
try:
times = int(self.request.args['times'])
except:
times = 1
resp = HttpResponse()
resp['Content-Type'] = 'text/plain'
for i in xrange(times):
resp.write('Hello %s!\n' % name)
return resp
class WebpyLike(WebpyApplication):
urls = [
(r'^(.*)$', HelloWorld)
]
app = WebpyLike
if __name__ == '__main__':
execute(app)
When the user requests data (REQUEST_METHOD is GET), it calls callback.GET. When the user sends form data to the application (REQUEST_METHOD is POST), WebpyApplication calls callback.POST.