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
                ):
    #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 ImportError 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)
Starts up and runs web application server and salt api server
dataset/ETHPy150Open saltstack/halite/halite/server_bottle.py/startServer