def main(server):
    """A convenience ``main`` method for running WSGI-compatible HTTP
       application as CGI, FCGI or standalone (with auto-detection)."""

    if 'REQUEST_METHOD' in os.environ:
        start_cgi(server)

    stdin_sock = socket.fromfd(0, socket.AF_UNIX, socket.SOCK_STREAM)
    try:
        stdin_sock.getpeername()
    except socket.error as e:
        if e.errno == errno.ENOTCONN:
            start_fcgi(server)

    start_standalone(server)