0
這是應用程序的根(http://site.com),它在請求域時運行。如果我只想添加一個文件,說robots.txt(http://site.com/robots.txt)被請求使用這個http服務器,我會怎麼做?它會從robots.txt中取出內容並將其回顯出來。使用node.js服務器請求文件
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('homepage');
res.end('');
}).listen(process.env.VMC_APP_PORT || 1337, null);
感謝
我建議使用[sendfile](http://blog.std.in/2010/09/09/using-sendfile-with-的NodeJS /) – Louis 2012-07-19 03:16:27