I am new to web app development. The pyhton file which displays 'Hello World' in the browser is
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello World')
app = webapp2.WSGIApplication([('/', MainHandler)
], debug=True)
What I couldn't understand is the function of the line
app = webapp2.WSGIApplication([('/', MainHandler) ], debug=True)
I have searched the net for the answer but failed to get a satisfactory answer. It would be great if anyone would explain it considering I am a beginner.
As far as I understand
webapp2.WSGIApplicationcreates a new listener on default port. When you type127.0.0.1/a browser will send a request to your application that listens the default port (I assume it's 80). Thewebapp2.WSGIApplicationlistener will create a new instance ofMainHandlerfor this request (and for every single request it receives) Then WSGIApplication will triggergetoverridden method ofMainHandlerto generate output. In the end of the day WSGIApplication will serve back output text.