/opt/imh-python/lib/python3.9/site-packages/cherrypy/tutorial
NameSizeModeActions
__pycache__/-0755rm
custom_error.html4040644editdlrm
pdf_file.pdf856980644editdlrm
README.rst6170644editdlrm
tut01_helloworld.py10150644editdlrm
tut02_expose_methods.py8010644editdlrm
tut03_get_and_post.py15870644editdlrm
tut04_complex_site.py29480644editdlrm
tut05_derived_objects.py21410644editdlrm
tut06_default_method.py22640644editdlrm
tut07_sessions.py12280644editdlrm
tut08_generators_and_yield.py12880644editdlrm
tut09_files.py34630644editdlrm
tut10_http_errors.py27060644editdlrm
tutorial.conf960644editdlrm
__init__.py850644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/cherrypy/tutorial/tut04_complex_site.py (2948B)
""" Tutorial - Multiple objects 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 '''

Hi, this is the home page! Check out the other fun stuff on this site:

''' class JokePage: @cherrypy.expose def index(self): return '''

"In Python, how do you create a string of random characters?" -- "Read a Perl file!"

[Return]

''' class LinksPage: def __init__(self): # Request handler objects can create their own nested request # handler objects. Simply create them inside their __init__ # 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 # absolute position in the site tree, since we use relative # links exclusively. return '''

Here are some useful links:

You can check out some extra useful links here.

[Return]

''' class ExtraLinksPage: @cherrypy.expose def index(self): # Note the relative link back to the Links page! return '''

Here are some extra useful links:

[Return to links page]

''' # Of course we can also mount request handler objects right here! root = HomePage() root.joke = JokePage() root.links = LinksPage() # Remember, we don't need to mount ExtraLinksPage here, because # LinksPage does that itself on initialization. In fact, there is # no reason why you shouldn't let your root object take care of # creating all contained request handler objects. tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf') if __name__ == '__main__': # CherryPy always starts with app.root when trying to map request URIs # 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)