How to use the cheroot.wsgi function in cheroot

To help you get started, we’ve selected a few cheroot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github h3llrais3r / Auto-Subliminal / lib / cheroot / View on Github external
import time

import pytest
from six.moves import http_client

import cheroot.server
from cheroot.test import webtest
import cheroot.wsgi

NO_INTERFACE = None  # Using this or '' will cause an exception

config = {
    cheroot.wsgi.Server: {
        'bind_addr': (NO_INTERFACE, EPHEMERAL_PORT),
        'wsgi_app': None,
    cheroot.server.HTTPServer: {
        'bind_addr': (NO_INTERFACE, EPHEMERAL_PORT),
        'gateway': cheroot.server.Gateway,

def cheroot_server(server_factory):
    """Set up and tear down a Cheroot server instance."""
    conf = config[server_factory].copy()
    bind_port = conf.pop('bind_addr')[-1]

    for interface in ANY_INTERFACE_IPV6, ANY_INTERFACE_IPV4:
github h3llrais3r / Auto-Subliminal / lib / cheroot / View on Github external
def wsgi_server():
    """Set up and tear down a Cheroot WSGI server instance."""
    for srv in cheroot_server(cheroot.wsgi.Server):
        yield srv
github cherrypy / cherrypy / cherrypy / View on Github external
def __init__(self, server, conn):
        """Initialize HTTP request container instance.

            server (cheroot.server.HTTPServer):
                web server object receiving this request
            conn (cheroot.server.HTTPConnection):
                HTTP connection object for this request
        super(CPWSGIHTTPRequest, self).__init__(
            server, conn, proxy_mode=True

class CPWSGIServer(cheroot.wsgi.Server):
    """Wrapper for cheroot.wsgi.Server.

    cheroot has been designed to not reference CherryPy in any way,
    so that it can be used in other frameworks and applications. Therefore,
    we wrap it here, so we can set our own mount points from cherrypy.tree
    and apply some attributes from config -> cherrypy.server -> wsgi.Server.

    fmt = 'CherryPy/{cherrypy.__version__} {cheroot.wsgi.Server.version}'
    version = fmt.format(**globals())

    def __init__(self, server_adapter=cherrypy.server):
        """Initialize CPWSGIServer instance.

            server_adapter (cherrypy._cpserver.Server): ...
github cherrypy / cheroot / cheroot / View on Github external
def server(self, parsed_args):
        return wsgi.Server(**self.server_args(parsed_args))
github AdrianVollmer / PowerHub / powerhub / View on Github external
        "/": {
            "root": WEBDAV_DIR,
            "readonly": True,
    "verbose": 1,

app = WsgiDAVApp(config)

server_args = {
    "bind_addr": (config["host"], config["port"]),
    "wsgi_app": app,
server = wsgi.Server(**server_args)

class MyHandler(FileSystemEventHandler):
    def on_created(self, event):
            os.path.join(BLACKHOLE_DIR, os.path.basename(event.src_path)),

def watch_blackhole_folder():
    observer = Observer()
    observer.schedule(MyHandler(), path=WEBDAV_BLACKHOLE, recursive=False)

github Dan-in-CA / SIP / web / View on Github external
def WSGIServer(server_address, wsgi_app):
    """Creates CherryPy WSGI server listening at `server_address` to serve `wsgi_app`.
    This function can be overwritten to customize the webserver or use a different webserver.
    from cheroot import wsgi

    server = wsgi.Server(server_address, wsgi_app, server_name="localhost")
    server.nodelay = not sys.platform.startswith(
    )  # TCP_NODELAY isn't supported on the JVM
    return server
github ralphwetzel / theonionbox / theonionbox / tob / View on Github external
def run(self, handler):  # pragma: no cover
                from cheroot import wsgi
                from cheroot.ssl import builtin
                self.options['bind_addr'] = (, self.port)
                self.options['wsgi_app'] = handler
                certfile = self.options.pop('certfile', None)
                keyfile = self.options.pop('keyfile', None)
                chainfile = self.options.pop('chainfile', None)
                self.server = wsgi.Server(**self.options)
                if certfile and keyfile:
                    self.server.ssl_adapter = builtin.BuiltinSSLAdapter(
                        certfile, keyfile, chainfile)