tut03_get_and_post.py (965B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\lib\cherrypy\tutorial\tut03_get_and_post.py 2 import cherrypy 3 4 class WelcomePage: 5 6 def index(self): 7 return '\n <form action="greetUser" method="GET">\n What is your name?\n <input type="text" name="name" />\n <input type="submit" />\n </form>' 8 9 index.exposed = True 10 11 def greetUser(self, name = None): 12 if name: 13 return "Hey %s, what's up?" % name 14 elif name is None: 15 return 'Please enter your name <a href="./">here</a>.' 16 else: 17 return 'No, really, enter your name <a href="./">here</a>.' 18 19 greetUser.exposed = True 20 21 22 import os.path 23 tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') 24 if __name__ == '__main__': 25 cherrypy.quickstart(WelcomePage(), config=tutconf) 26 else: 27 cherrypy.tree.mount(WelcomePage(), config=tutconf)