diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2017-12-17 12:34:32 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-12-17 12:38:41 -0500 |
| commit | 661dc06ffa9a872824d628975657b21325654f2e (patch) | |
| tree | 36027d71593578354faf50c5a227cf637388a4ff /cherrypy/tutorial/tut04_complex_site.py | |
| parent | 49bc467811b74e100a6f5e007409e9d9baaa5f6a (diff) | |
| parent | 0e4542295a33fd776f2ca5f1bb151eb8ddf919a0 (diff) | |
| download | cherrypy-git-archive/1285-always-bytes.tar.gz | |
Merge branch 'master' into bb-pr-85archive/1285-always-bytes
Diffstat (limited to 'cherrypy/tutorial/tut04_complex_site.py')
| -rw-r--r-- | cherrypy/tutorial/tut04_complex_site.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/cherrypy/tutorial/tut04_complex_site.py b/cherrypy/tutorial/tut04_complex_site.py index e0660024..3caa1775 100644 --- a/cherrypy/tutorial/tut04_complex_site.py +++ b/cherrypy/tutorial/tut04_complex_site.py @@ -5,11 +5,14 @@ This tutorial shows you how to create a site structure through multiple possibly nested request handler objects. """ +import os.path + import cherrypy class HomePage: + @cherrypy.expose def index(self): return ''' <p>Hi, this is the home page! Check out the other @@ -19,17 +22,16 @@ class HomePage: <li><a href="/joke/">A silly joke</a></li> <li><a href="/links/">Useful links</a></li> </ul>''' - index.exposed = True class JokePage: + @cherrypy.expose def index(self): return ''' <p>"In Python, how do you create a string of random characters?" -- "Read a Perl file!"</p> <p>[<a href="../">Return</a>]</p>''' - index.exposed = True class LinksPage: @@ -40,6 +42,7 @@ class LinksPage: # methods! self.extra = ExtraLinksPage() + @cherrypy.expose def index(self): # Note the way we link to the extra links page (and back). # As you can see, this object doesn't really care about its @@ -62,11 +65,11 @@ class LinksPage: <p>[<a href="../">Return</a>]</p> ''' - index.exposed = True class ExtraLinksPage: + @cherrypy.expose def index(self): # Note the relative link back to the Links page! return ''' @@ -78,7 +81,6 @@ class ExtraLinksPage: </ul> <p>[<a href="../">Return to links page</a>]</p>''' - index.exposed = True # Of course we can also mount request handler objects right here! @@ -92,7 +94,6 @@ root.links = LinksPage() # creating all contained request handler objects. -import os.path tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') if __name__ == '__main__': @@ -100,6 +101,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(root, config=tutconf) -else: - # This branch is for the test suite; you can ignore it. - cherrypy.tree.mount(root, config=tutconf) |
