Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

root/tags/cherrypy-2.0.0/cherrypy/tutorial/02_expose_methods.py

Revision 102 (checked in by dpotter, 4 years ago)

add descriptive names to the tutorials

Line 
1 """
2 Tutorial 02 - Multiple methods
3
4 This tutorial shows you how to link to other methods of your request
5 handler.
6 """
7
8 from cherrypy import cpg
9
10 class HelloWorld:
11
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
16     index.exposed = True
17
18
19     def showMessage(self):
20         # Here's the important message!
21         return "Hello world!"
22
23     showMessage.exposed = True
24
25 cpg.root = HelloWorld()
26 cpg.server.start(configFile = 'tutorial.conf')
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets