__init__.py :  » Web-Server » CherryPy » CherryPy-3.1.2 » cherrypy » scaffold » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Server » CherryPy 
CherryPy » CherryPy 3.1.2 » cherrypy » scaffold » __init__.py
"""<MyProject>, a CherryPy application.

Use this as a base for creating new CherryPy applications. When you want
to make a new app, copy and paste this folder to some other location
(maybe site-packages) and rename it to the name of your project,
then tweak as desired.

Even before any tweaking, this should serve a few demonstration pages.
Change to this directory and run:

    python cherrypy\cherryd -c cherrypy\scaffold\site.conf

"""

import cherrypy
from cherrypy import tools,url

import os
local_dir = os.path.join(os.getcwd(), os.path.dirname(__file__))


class Root:
    
    _cp_config = {'tools.log_tracebacks.on': True,
                  }
    
    def index(self):
        return """<html>
<body>Try some <a href='%s?a=7'>other</a> path,
or a <a href='%s?n=14'>default</a> path.<br />
Or, just look at the pretty picture:<br />
<img src='%s' />
</body></html>""" % (url("other"), url("else"),
                     url("files/made_with_cherrypy_small.png"))
    index.exposed = True
    
    def default(self, *args, **kwargs):
        return "args: %s kwargs: %s" % (args, kwargs)
    default.exposed = True
    
    def other(self, a=2, b='bananas', c=None):
        cherrypy.response.headers['Content-Type'] = 'text/plain'
        if c is None:
            return "Have %d %s." % (int(a), b)
        else:
            return "Have %d %s, %s." % (int(a), b, c)
    other.exposed = True
    
    files = cherrypy.tools.staticdir.handler(
                section="/files",
                dir=os.path.join(local_dir, "static"),
                # Ignore .php files, etc.
                match=r'\.(css|gif|html?|ico|jpe?g|js|png|swf|xml)$',
                )


root = Root()

# Uncomment the following to use your own favicon instead of CP's default.
#favicon_path = os.path.join(local_dir, "favicon.ico")
#root.favicon_ico = tools.staticfile.handler(filename=favicon_path)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.