1 """<MyProject>, a CherryPy application.
3 Use this as a base for creating new CherryPy applications. When you want
4 to make a new app, copy and paste this folder to some other location
5 (maybe site-packages) and rename it to the name of your project,
8 Even before any tweaking, this should serve a few demonstration pages.
9 Change to this directory and run:
11 ../cherryd -c site.conf
16 from cherrypy
import tools
, url
19 local_dir
= os
.path
.join(os
.getcwd(), os
.path
.dirname(__file__
))
24 _cp_config
= {'tools.log_tracebacks.on': True,
29 <body>Try some <a href='%s?a=7'>other</a> path,
30 or a <a href='%s?n=14'>default</a> path.<br />
31 Or, just look at the pretty picture:<br />
33 </body></html>""" % (url("other"), url("else"),
34 url("files/made_with_cherrypy_small.png"))
37 def default(self
, *args
, **kwargs
):
38 return "args: %s kwargs: %s" % (args
, kwargs
)
39 default
.exposed
= True
41 def other(self
, a
=2, b
='bananas', c
=None):
42 cherrypy
.response
.headers
['Content-Type'] = 'text/plain'
44 return "Have %d %s." % (int(a
), b
)
46 return "Have %d %s, %s." % (int(a
), b
, c
)
49 files
= cherrypy
.tools
.staticdir
.handler(
51 dir=os
.path
.join(local_dir
, "static"),
52 # Ignore .php files, etc.
53 match
=r
'\.(css|gif|html?|ico|jpe?g|js|png|swf|xml)$',
59 # Uncomment the following to use your own favicon instead of CP's default.
60 #favicon_path = os.path.join(local_dir, "favicon.ico")
61 #root.favicon_ico = tools.staticfile.handler(filename=favicon_path)