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