1. 程式人生 > >用node.js搭建服務器

用node.js搭建服務器

host post local create div console reat node 集成

//先在集成終端輸出(啟動);在輸入網址(127.0.0.1:3000)或locallhost:3000

//搭建服務器

const http = require("http"); //引入http模板 let server = http.createServer(function(req,res){ //request請求 response響應 res.write("<head><meta charset =‘utf-8‘></head>") res.write("<body><h1>hello word 你好啊.世界<h1></body>"); res.end(); }); // server.listen(3000); //監聽 2種寫法 server.listen(3000,function(){ console/log("嘿嘿,你在幹嘛呢"); })




//查看自己的IP地址;window+R輸入cmd再輸入ipconfig

用node.js搭建服務器