与this question for Express类似,是否有一种编程方式来获取正在运行的Connect服务器的主机名和端口号?
答案 0 :(得分:0)
很简单:
var http = require('http');
var connect = require('connect');
var app = connect().use(connect.static(__dirname)); //or any other use
var server = http.createServer(app).listen(port, host, callback);
答案 1 :(得分:0)
想出来:
var connect = require("connect");
var server = require("http").createServer(connect());
server.listen(function() {
console.log(server.address()); // Print host name and port number.
});