Create an HTTP server that always yield 200 HTTP status code
@param  {number} port
@param  {function} [f]    callback
437847
function createServer(port, f) {
  f = f || noop;
  http.createServer(handler).listen(port, f);
  return statusHelper.changeStatus;
}
1235440
def run_server(port=8000):
    
    from http.server import BaseHTTPRequestHandler, HTTPServer

    class VerboseHTMLHandler(BaseHTTPRequestHandler):
        def do_HEAD(s):
            s.send_response(200)
            s.send_header("Content-type", "text/html")
            s.end_headers()

        def do_GET(s):
            global html

            data = changed_file()
            if data is not None:
                html = html_from_markdown(data)
            s.send_response(200)
            s.send_header("Content-type", "text/html")
            s.end_headers()
            s.wfile.write(standalone(html).encode('utf-8'))

    class SilentHTMLHandler(VerboseHTMLHandler):
        def log_message(self, format, *args):
            return

    port = int(port)
    server_class = HTTPServer
    handler = VerboseHTMLHandler if verbose else SilentHTMLHandler
    try:
        httpd = server_class(("localhost", port), handler)
    except PermissionError:
        sys.stderr.write("Permission denied\n")
        sys.exit(1)
    if verbose:
        print("Hosting server on port %d. Ctrl-c to exit" % port)
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    if verbose:
        print("\rShutting down server")
1065787
function(error, callback) {
      if (!this.serverURL) {
        return false;
      }

      var xhr = new XMLHttpRequest();
      xhr.open('POST', this.serverURL, true);
      xhr.onreadystatechange = function() {
        if (xhr.readyState === 4) {
          typeof callback === 'function' && callback(error, xhr.status === 200);
        }
      };

      xhr.setRequestHeader('Content-Type', 'application/json');
      xhr.send(JSON.stringify(error));
    }
563780
function (options, callbackFn) {
            var self = this;

            //compensate for optional options parm
            if (typeof options === 'function') {
                callbackFn = options;
                options = {};
            }

            //assign default port
            options.port = options.port || 1061;
            options.host = options.host || 'localhost';
            options.hostAndPort = 'http://' + options.host + ':' + options.port;
            options.eventStreamPath = require('path').normalize(__dirname + '/../temp/events.txt');
            options.phantomjsPath = options.phantomjsPath || 'phantomjs';

            options.debug && console.log('creating proxy to %s', options.hostAndPort);

            this.options = options;

            //try starting server
            createServer.call(self, options, function (proxy) {
                callbackFn.call(self, proxy);
            });

            return this;//return this to chain end
        }
55018
function Server(transport, keyFilePath, crtFilePath) {
	X224.call(this, transport);
	this.keyFilePath = keyFilePath;
	this.crtFilePath = crtFilePath;
	var self = this;
	this.transport.once('data', function (s) {
		self.recvConnectionRequest(s);
	});
}
871428
function (url, cb) {

            var request = new XMLHttpRequest();

            request.onload = function () {
                if (this.status >= 200 && this.status < 400) {
                    cb(this.response);
                }
                else {
                    Logger.log(Logger.LEVEL_SEVERE, "sever error: " + this.status);
                    cb(null);
                }
            };

            request.onerror = function (e) {
                Logger.log(Logger.LEVEL_SEVERE, "connection error: " + e);
                cb(null);
            };

            request.open("get", url, true);

            request.send();
        }
1041044
function(port, options) {
    var stream = new SimpleStream();
    var prompt = 'node> ';
    var rs = repl.start({ prompt: prompt, input: stream, output: stream});
    var replHttpServer = new ReplHttpServer(prompt, stream, rs, options);
    replHttpServer.start(port);
    return rs;
}
32759
function summary (server, write) {
  assert.ok(server instanceof http.Server, /expected instance of server/)
  write = write || defaultWrite

  return function () {
    const address = server.address()
    const port = address.port
    const url = 'http://localhost:' + port
    const env = process.env.NODE_ENV || 'undefined'

    write({
      port: port,
      env: env,
      pid: process.pid,
      url: url
    })
  }
}
1307762
function makeRequest(options, callback) {
    request(options, function (error, response, body){
        if (error) {
            callback(error, null);
        }
        else if (response.statusCode == 200) {
            callback( null, JSON.parse(body));
        }
        else {
            callback(new Error('HTTP Response Code: ' + response.statusCode), null);
        }
    });
}
901644
def start_http_server(port, addr='', registry=REGISTRY):
    """"""
    CustomMetricsHandler = MetricsHandler.factory(registry)
    httpd = _ThreadingSimpleServer((addr, port), CustomMetricsHandler)
    t = threading.Thread(target=httpd.serve_forever)
    t.daemon = True
    t.start()
1107809
function WebServer(data) {
  // Use a closure to preserve `this`
  var self = this;
  self.data = data;

  this.RequestHandler = bind(this.RequestHandler, this);
  this.callbackExecutor = bind(this.callbackExecutor, this);

  self.server = http.createServer(self.RequestHandler);

  // Use random port if port settings is not provided.
  if (!self.data.port) {
    self.data.port = 0;
  }

  // Use address if provided.
  if (self.data.hostname) {
    self.server.listen(self.data.port, self.data.hostname);
  } else {
    self.server.listen(self.data.port);
  }

  self.server.on('listening', function() {
    self.debug.log('Listen on :%s', self.server.address().port);
  });
}
1337643
function startAppServer(fn) {
  if (!checkingAppServerPort) {
    server = fork(appServer.file, [], appServer.options);
    server.on('exit', code => {
      checkingAppServerPort = false;
      server.removeAllListeners();
      server = null;
      fn(Error('failed to start server'));
    });

    checkingAppServerPort = true;
    waitForPortOpen(appServer.port, fn);
  }
}
125401
function tail (argv, callback) {
  if (!argv[2]) {
    console.error('url is required')
    console.error('Usage : tail <url>')
    process.exit(-1)
  }
  var uri = argv[2]
  var wss = 'wss://' + uri.split('/')[2] + '/'

  var s = new ws(wss, {
    origin: 'http://websocket.org'
  })

  s.on('open', function open () {
    s.send('sub ' + uri)
  })

  s.on('close', function close () {
    console.log('disconnected')
  })

  s.on('message', function message (data, flags) {
    var a = data.split(' ')
    if (a.length && a[0] === 'pub') {
      util.get(a[1], function (err, res) {
        if (err) {
          console.error('Error : ' + err)
        } else {
          console.log(res)
        }
      })
    }
  })
}
810885
function(callback) {
        server = illyria2.createServer();
        server.expose("benchmark", {
            echo: function(req, resp) {
                resp.send(req.params());
            }
        });
        server.listen(SERVER_PORT, function() {
            callback();
        });
    }
606285
function ping(options, callback) {
  const args = utils.getArgs(options, [config], callback);
  const url = `http://${args.options.ip}:${args.options.port}/ping`;

  return request.get(url, function(err) {
    if (err) {
      if (err.code === "ECONNREFUSED") {
        return args.callback(null, { running: false });
      }
      return args.callback(err);
    }
    return args.callback(null, { running: true });
  });
}
266256
function TCPSocket(port) {

    var self = this;

    this.server = net.createServer(function(socket) {

        socket.setEncoding('utf8');

        self.on('message', function(message) {

            logger.log('debug', 'TCP socket:', message);
            //var jsonMessage = message.getJSON();
        });

        socket.on('data', function(jsonMessage) {

            // There may be multiple messages in each chunk of TCP data.
            var messageArray = JSON.parse('[' + jsonMessage.replace('}\r\n{', '},{') + ']');

            _.each(messageArray, function(message) {
                console.log('Received message', message);
                var message = new Message(message);
                self.emit('message', message);
            });
        }); 

        // Add a 'close' event handler for the TCPClient socket
        socket.on('close', function() {

            socket.removeListener('data');
            self.removeListener('message');
            logger.info('TCP socket disconnected');
        }); 

        self.socket = socket;

        logger.info('TCP socket connected');

    }).listen(port);
}
390817
function init (prefs, callback) {
	options = _.extend(defaults, prefs);
	app = options.app || express();
	app.use(cors());

	ramlMocker.generate(options, process(function(requestsToMock){
		requestsToMock.forEach(function(reqToMock){
			addRoute(reqToMock);
		});
		log(new Array(30).join('='));
		log('%s[%s]%s API routes generated', colors.qyan, requestsToMock.length, colors.default);

		if(typeof callback === 'function'){
			callback(app);
		}
	}));

	var watcher = watch();
	var server = launchServer(app);

	function close () {
		if (watcher) { watcher.close(); }
		if (server) { server.close(); }
	}

	return {
		close: close,
		server: server,
		watcher: watcher
	};
}