cherrypy package¶
Subpackages¶
- cherrypy.lib package
- Submodules
- cherrypy.lib.auth module
- cherrypy.lib.auth_basic module
- cherrypy.lib.auth_digest module
- cherrypy.lib.caching module
- cherrypy.lib.covercp module
- cherrypy.lib.cpstats module
- cherrypy.lib.cptools module
- cherrypy.lib.encoding module
- cherrypy.lib.gctools module
- cherrypy.lib.httpauth module
- cherrypy.lib.httputil module
- cherrypy.lib.jsontools module
- cherrypy.lib.lockfile module
- cherrypy.lib.locking module
- cherrypy.lib.profiler module
- cherrypy.lib.reprconf module
- cherrypy.lib.sessions module
- cherrypy.lib.static module
- cherrypy.lib.xmlrpcutil module
- Module contents
- cherrypy.process package
- cherrypy.scaffold package
- cherrypy.test package
- Submodules
- cherrypy.test.benchmark module
- cherrypy.test.checkerdemo module
- cherrypy.test.helper module
- cherrypy.test.logtest module
- cherrypy.test.modfastcgi module
- cherrypy.test.modfcgid module
- cherrypy.test.modpy module
- cherrypy.test.modwsgi module
- cherrypy.test.sessiondemo module
- cherrypy.test.test_auth_basic module
- cherrypy.test.test_auth_digest module
- cherrypy.test.test_bus module
- cherrypy.test.test_caching module
- cherrypy.test.test_compat module
- cherrypy.test.test_config module
- cherrypy.test.test_config_server module
- cherrypy.test.test_conn module
- cherrypy.test.test_core module
- cherrypy.test.test_dynamicobjectmapping module
- cherrypy.test.test_encoding module
- cherrypy.test.test_etags module
- cherrypy.test.test_http module
- cherrypy.test.test_httpauth module
- cherrypy.test.test_httplib module
- cherrypy.test.test_iterator module
- cherrypy.test.test_json module
- cherrypy.test.test_logging module
- cherrypy.test.test_mime module
- cherrypy.test.test_misc_tools module
- cherrypy.test.test_objectmapping module
- cherrypy.test.test_params module
- cherrypy.test.test_proxy module
- cherrypy.test.test_refleaks module
- cherrypy.test.test_request_obj module
- cherrypy.test.test_routes module
- cherrypy.test.test_session module
- cherrypy.test.test_sessionauthenticate module
- cherrypy.test.test_states module
- cherrypy.test.test_static module
- cherrypy.test.test_tools module
- cherrypy.test.test_tutorials module
- cherrypy.test.test_virtualhost module
- cherrypy.test.test_wsgi_ns module
- cherrypy.test.test_wsgi_unix_socket module
- cherrypy.test.test_wsgi_vhost module
- cherrypy.test.test_wsgiapps module
- cherrypy.test.test_xmlrpc module
- cherrypy.test.webtest module
- Module contents
- cherrypy.tutorial package
- Submodules
- cherrypy.tutorial.tut01_helloworld module
- cherrypy.tutorial.tut02_expose_methods module
- cherrypy.tutorial.tut03_get_and_post module
- cherrypy.tutorial.tut04_complex_site module
- cherrypy.tutorial.tut05_derived_objects module
- cherrypy.tutorial.tut06_default_method module
- cherrypy.tutorial.tut07_sessions module
- cherrypy.tutorial.tut08_generators_and_yield module
- cherrypy.tutorial.tut09_files module
- cherrypy.tutorial.tut10_http_errors module
- Module contents
Submodules¶
cherrypy.daemon module¶
The CherryPy daemon.
Module contents¶
CherryPy is a pythonic, object-oriented HTTP framework.
CherryPy consists of not one, but four separate API layers.
The APPLICATION LAYER is the simplest. CherryPy applications are written as a tree of classes and methods, where each branch in the tree corresponds to a branch in the URL path. Each method is a ‘page handler’, which receives GET and POST params as keyword arguments, and returns or yields the (HTML) body of the response. The special method name ‘index’ is used for paths that end in a slash, and the special method name ‘default’ is used to handle multiple paths via a single handler. This layer also includes:
- the ‘exposed’ attribute (and cherrypy.expose)
- cherrypy.quickstart()
- _cp_config attributes
- cherrypy.tools (including cherrypy.session)
- cherrypy.url()
The ENVIRONMENT LAYER is used by developers at all levels. It provides information about the current request and response, plus the application and server environment, via a (default) set of top-level objects:
- cherrypy.request
- cherrypy.response
- cherrypy.engine
- cherrypy.server
- cherrypy.tree
- cherrypy.config
- cherrypy.thread_data
- cherrypy.log
- cherrypy.HTTPError, NotFound, and HTTPRedirect
- cherrypy.lib
The EXTENSION LAYER allows advanced users to construct and share their own plugins. It consists of:
- Hook API
- Tool API
- Toolbox API
- Dispatch API
- Config Namespace API
Finally, there is the CORE LAYER, which uses the core API’s to construct the default components which are available at higher layers. You can think of the default components as the ‘reference implementation’ for CherryPy. Megaframeworks (and advanced users) may replace the default components with customized or extended components. The core API’s are:
- Application API
- Engine API
- Request API
- Server API
- WSGI API
These API’s are described in the CherryPy specification.
-
cherrypy.
quickstart
(root=None, script_name='', config=None)[source]¶ Mount the given root, start the builtin server (and engine), then block.
- root: an instance of a “controller class” (a collection of page handler
- methods) which represents the root of the application.
- script_name: a string containing the “mount point” of the application.
This should start with a slash, and be the path portion of the URL at which to mount the given root. For example, if root.index() will handle requests to “http://www.example.com:8080/dept/app1/”, then the script_name argument would be “/dept/app1”.
It MUST NOT end in a slash. If the script_name refers to the root of the URI, it MUST be an empty string (not “/”).
- config: a file or dict containing application config. If this contains
- a [global] section, those entries will be used in the global (site-wide) config.