def startServer(level='info',
                server='paste',
                host='0.0.0.0',
                port='8080',
                base='',
                cors=False,
                tls=False,
                certpath='/etc/pki/tls/certs/localhost.crt',
                keypath='/etc/pki/tls/certs/localhost.key',
                pempath='/etc/pki/tls/certs/localhost.pem',
                devel=False,
                coffee=False,
                opts=None,
                **kwas
                ):
    '''
    Starts up and runs web application server and salt api server
    Parameters:
        level = logging level string, default is 'info'
        server = server name string, default is 'paste'
        host = host address or domain name string, default is '0.0.0.0'
        port = port number string, default is '8080'
        base = url path base prefix string, default is ''
        cors = enable CORS if truthy, default is False
        tls = use tls/ssl if Truthy, default is False
        certpath = pathname string to ssl certificate file, default is
                   '/etc/pki/tls/certs/localhost.crt'
        keypath = pathname string to ssl private key file, default is
                   '/etc/pki/tls/certs/localhost.key'
        pempath = pathname string to ssl pem file with both cert and private key,
                   default is '/etc/pki/tls/certs/localhost.pem'
        devel = generate main.html if truthy on each request in support of development
                   default is False
        coffee = generate main.html to load and compile coffeescript if truthy when
                   devel is true. Default is False
        kwas = additional keyword arguments dict that are passed as server options
    Does not return.
    '''
    #so when using gevent can monkey patch before import bottle
    global gevented, gevent, bottle

    logger.setLevel(aiding.LOGGING_LEVELS[level])
    gevented = False
    if server in ['gevent']:
        try:
            import gevent
            from gevent import monkey
            monkey.patch_all()
            gevented = True
        except __HOLE__ as ex: #gevent support not available
            server = 'paste' # use default server

    tlsOptions = {}
    tlsOptions['paste'] = {'ssl_pem': pempath}
    tlsOptions['gevent'] = {'keyfile': keypath, 'certfile': certpath}
    tlsOptions['cherrypy'] = {'keyfile': keypath, 'certfile': certpath}

    options = dict(**kwas)
    if tls and server in tlsOptions:
        options.update(**tlsOptions[server]) # retrieve ssl options for server

    import bottle

    app = bottle.default_app() # create bottle app

    loadErrors(app)
    loadWebUI(app, devel=devel, coffee=coffee)
    loadSaltApi(app, opts)
    if cors:
        loadCors(app)
    app = rebase(base=base)

    logger.info("Running web application server '{0}' on {1}:{2}.".format(
        server, host, port))

    if base:
        logger.info("URL paths rebased after base '{0}".format(base))
    logger.info("CORS is {0}.".format('enabled' if cors else 'disabled'))
    logger.info("TLS/SSL is {0}.".format('enabled' if tls else 'disabled'))
    logger.info("Server options: \n{0}".format(options))

    bottle.run( app=app,
                server=server,
                host=host,
                port=port,
                debug=devel,
                reloader=devel and not gevented,
                interval=1,
                quiet=False,
                **options)
dataset/ETHPy150Open saltstack/halite/halite/server_bottle.py/startServer