Node.js学习(一)起一个简单的服务

247 阅读1分钟
const http = require("http");
http.createServer((req, res) => {
    // 定义http头
    res.writeHead(200, {
        "Content-Type":"text/plan"
    });
    // 发送相应数据
    res.end("hello world!\n");
}).listen(3000);
console.log("node 服务已启动...");