Package wsgiserver
source code
A 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!
']
# Here we set our application to the script_name '/'
wsgi_apps = [('/', my_crazy_app)]
server = wsgiserver.CherryPyWSGIServer(('localhost', 8070), wsgi_apps,
server_name='localhost')
# 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 it's coupling.
The CherryPy WSGI server can serve as many WSGI applications
as you want in one instance:
wsgi_apps = [('/', my_crazy_app), ('/blog', my_blog_app)]
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.
|
socket_errors_to_ignore
- Value:
[ 32, 104, 110, 111, 112, 113, ' timed out ' ]
|
|
comma_separated_headers
- Value:
[ ' ACCEPT ' ,
' ACCEPT-CHARSET ' ,
' ACCEPT-ENCODING ' ,
' ACCEPT-LANGUAGE ' ,
' ACCEPT-RANGES ' ,
' ALLOW ' ,
' CACHE-CONTROL ' ,
' CONNECTION ' ,
...
|
|