Rumah > Soal Jawab > teks badan
function onRequest(request, response, modules) {
var a = require('http');
a.createServer(function (req, res) {
req.setEncoding('utf8');
var postData = "";
req.addListener("data", function (chunk) {
postData += chunk;
});
req.addListener("end", function () {
var resp = function (ret, status_code) {
res.writeHead(status_code, {
"Content-Type": "text/plain; charset=utf-8"
});
res.end(ret);
}
});
}).listen(8080, "0.0.0.0");
}
巴扎黑2017-04-17 13:22:48
require()
是nodejs
的内置函数,如果是在nodejs
环境下运行时不存在这个问题的https://nodejs.org/dist/latest-v5.x/docs/api/http.html