1 """
2 Tutorial - Passing variables
3
4 This tutorial shows you how to pass GET/POST variables to methods.
5 """
6
7 import cherrypy
8
9
11
13
14 return '''
15 <form action="greetUser" method="GET">
16 What is your name?
17 <input type="text" name="name" />
18 <input type="submit" />
19 </form>'''
20 index.exposed = True
21
22 - def greetUser(self, name=None):
23
24
25
26
27
28
29
30
31 if name:
32
33 return "Hey %s, what's up?" % name
34 else:
35 if name is None:
36
37 return 'Please enter your name <a href="./">here</a>.'
38 else:
39 return 'No, really, enter your name <a href="./">here</a>.'
40 greetUser.exposed = True
41
42
43 import os.path
44 tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
45
46 if __name__ == '__main__':
47
48
49
50 cherrypy.quickstart(WelcomePage(), config=tutconf)
51 else:
52
53 cherrypy.tree.mount(WelcomePage(), config=tutconf)
54