diff options
author | Robert Brewer <fumanchu@aminus.org> | 2005-06-10 19:54:04 +0000 |
---|---|---|
committer | Robert Brewer <fumanchu@aminus.org> | 2005-06-10 19:54:04 +0000 |
commit | f29f394614a30fe5e77fa0f89caaca078d2bf5a8 (patch) | |
tree | 29b2f89dc380aee7d27f5f480133ae718506debf /cherrypy/tutorial/tut01_helloworld.py | |
parent | 39670134d00e50350fac89de2e81061d67b27f68 (diff) | |
download | cherrypy-git-f29f394614a30fe5e77fa0f89caaca078d2bf5a8.tar.gz |
Merged new test suite from branches/ticket-177 into trunk.
Diffstat (limited to 'cherrypy/tutorial/tut01_helloworld.py')
-rw-r--r-- | cherrypy/tutorial/tut01_helloworld.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cherrypy/tutorial/tut01_helloworld.py b/cherrypy/tutorial/tut01_helloworld.py new file mode 100644 index 00000000..340c5af6 --- /dev/null +++ b/cherrypy/tutorial/tut01_helloworld.py @@ -0,0 +1,34 @@ +""" +Tutorial 01 - Hello World + +The most basic (working) CherryPy application possible. +""" + +# Import CherryPy global namespace +from cherrypy import cpg + +class HelloWorld: + """ Sample request handler class. """ + + def index(self): + # CherryPy will call this method for the root URI ("/") and send + # its return value to the client. Because this is tutorial + # lesson number 01, we'll just send something really simple. + # How about... + return "Hello world!" + + # Expose the index method through the web. CherryPy will never + # publish methods that don't have the exposed attribute set to True. + index.exposed = True + +# CherryPy always starts with cpg.root when trying to map request URIs +# to objects, so we need to mount a request handler object here. A request +# to '/' will be mapped to cpg.root.index(). +cpg.root = HelloWorld() + +if __name__ == '__main__': + # Use the configuration file tutorial.conf. + cpg.config.update(file = 'tutorial.conf') + # Start the CherryPy server. + cpg.server.start() + |