Fixed python_path problem.
[smonitor.git] / lib / cherrypy / tutorial / tut02_expose_methods.py
blob600fca340be95adf151f8e7b7676201490c3a500
1 """
2 Tutorial - Multiple methods
4 This tutorial shows you how to link to other methods of your request
5 handler.
6 """
8 import cherrypy
10 class HelloWorld:
12 def index(self):
13 # Let's link to another method here.
14 return 'We have an <a href="showMessage">important message</a> for you!'
15 index.exposed = True
17 def showMessage(self):
18 # Here's the important message!
19 return "Hello world!"
20 showMessage.exposed = True
22 import os.path
23 tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
25 if __name__ == '__main__':
26 # CherryPy always starts with app.root when trying to map request URIs
27 # to objects, so we need to mount a request handler root. A request
28 # to '/' will be mapped to HelloWorld().index().
29 cherrypy.quickstart(HelloWorld(), config=tutconf)
30 else:
31 # This branch is for the test suite; you can ignore it.
32 cherrypy.tree.mount(HelloWorld(), config=tutconf)