13.1 Example: Hello World

Let’s see a basic usage of the framework:

    # Import from itools
    from itools.web import Server, Root

    class MyRoot(Root):

        GET__access__ = True
        def GET(self, context):
            return 'Hello World'


    if __name__ == '__main__':
        root = MyRoot()
        server = Server(root)
        server.start()

To test the code above, type:

    $ python hello.py

Then open a browser and go to http://localhost:8080 to see the famous sentence.

These few lines of code expose several aspects of itools.web that we will see later with more detail: