0
我定義下一個HTTP請求:的node.js/get請求&在HTTP模塊定義根文件夾
var http = require("http");
http.get("http://localhost:8001/pro.html", function(respond) {
check();}).on('error', function(e) {
console.log("Got err: " + e.message);
});
現在,在服務器側I定義下一個:
var server = net.createServer(function(socket) {
// Some code
socket.on('data', function(d) {
var t = http.request(d, function (res){
console.log(d);
console.log(res.statusCode);
});
// Some code}
我有兩個問題:
- 什麼都不打印。爲什麼它沒有達到
console.log(d);console.log(res.statusCode);
? - Pro.html位於
c://myFolder
。我如何告訴我的服務器這個頁面的位置?
謝謝。
什麼是d,它沒有在你的代碼中定義? – mpm
@mpm:對不起,我改正了 – user2579252