Module wsgiserver
source code
high-speed, production ready, thread pooled, generic WSGI server.
Simplest example on how to use this module directly
(without using CherryPy's application machinery):
from cherrypy import wsgiserver
def my_crazy_app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type','text/plain')]
start_response(status, response_headers)
return ['Hello world!
']
server = wsgiserver.CherryPyWSGIServer(
('0.0.0.0', 8070), my_crazy_app,
server_name='www.cherrypy.example')
The CherryPy WSGI server can serve as many WSGI applications
as you want in one instance by using a WSGIPathInfoDispatcher:
d = WSGIPathInfoDispatcher({'/': my_crazy_app, '/blog': my_blog_app})
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 80), d)
Want SSL support? Just set these attributes:
server.ssl_certificate = <filename>
server.ssl_private_key = <filename>
if __name__ == '__main__':
try:
server.start()
except KeyboardInterrupt:
server.stop()
This won't call the CherryPy engine (application side) at all, only the
WSGI server, which is independant from the rest of CherryPy. Don't
let the name "CherryPyWSGIServer" throw you; the name merely reflects
its origin, not its coupling.
|
|
quoted_slash = re.compile(r'(?i)%2F')
|
|
|
socket_errors_to_ignore = [32, 64, 65, 54, 60, 61, 'timed out']
|
|
|
socket_errors_nonblocking = [35]
|
|
|
comma_separated_headers = ['ACCEPT', 'ACCEPT-CHARSET', 'ACCEPT...
|
|
|
_SHUTDOWNREQUEST = None
|
|
Return error numbers for all errors in errnames on this platform.
The 'errno' module contains different global constants depending on
the specific platform (OS). This function will return the list of numeric
values for a given list of potential names.
|
Wrap the given method with SSL error-trapping.
is_reader: if False (the default), EOF errors will be raised.
If True, EOF errors will return "" (to emulate normal sockets).
|
|
Like print_exc() but return a string. Backport for Python 2.3.
|
comma_separated_headers
- Value:
['ACCEPT',
'ACCEPT-CHARSET',
'ACCEPT-ENCODING',
'ACCEPT-LANGUAGE',
'ACCEPT-RANGES',
'ALLOW',
'CACHE-CONTROL',
'CONNECTION',
...
|
|