I’m starting with the official tutorial on webpy.org site, which can be found at http://webpy.org/docs/0.3/tutorial
They introduce a little bit about URL, which results at the using of it in code by using a list of mapping URL, something like:
url = (
‘/’ , ‘index’
The first part, ‘/’ ( slash) is the regex ( regular express) that is used to represent the URL. Here we got a slash only , that mean the root directory of our web app. And text “index” is the name of class ( or ‘Handler’ class ) that will handle the request to this corresponding URL(s). URL in plural because we may have multiple urls that qualifies the regex definition here.
Next, we need to define the ‘hander’ class called ‘index’ that we mentioned above.
return “Hello GET request”
And we can start our very first app now by:
if __name__ == “__main__”:
app = web.application(url, globals())
Ola, we’re done with the very simple app.