summaryrefslogtreecommitdiff
path: root/cherrypy/tutorial/tut02_expose_methods.py
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/tutorial/tut02_expose_methods.py')
-rw-r--r--cherrypy/tutorial/tut02_expose_methods.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/cherrypy/tutorial/tut02_expose_methods.py b/cherrypy/tutorial/tut02_expose_methods.py
index 64a10f26..8afbf7d8 100644
--- a/cherrypy/tutorial/tut02_expose_methods.py
+++ b/cherrypy/tutorial/tut02_expose_methods.py
@@ -5,22 +5,24 @@ This tutorial shows you how to link to other methods of your request
handler.
"""
+import os.path
+
import cherrypy
class HelloWorld:
+ @cherrypy.expose
def index(self):
# Let's link to another method here.
return 'We have an <a href="show_msg">important message</a> for you!'
- index.exposed = True
+ @cherrypy.expose
def show_msg(self):
# Here's the important message!
- return "Hello world!"
- show_msg.exposed = True
+ return 'Hello world!'
+
-import os.path
tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
if __name__ == '__main__':
@@ -28,6 +30,3 @@ if __name__ == '__main__':
# to objects, so we need to mount a request handler root. A request
# to '/' will be mapped to HelloWorld().index().
cherrypy.quickstart(HelloWorld(), config=tutconf)
-else:
- # This branch is for the test suite; you can ignore it.
- cherrypy.tree.mount(HelloWorld(), config=tutconf)