1. 搭建本地服務器
-
const爲ES6新增量,可以理解爲常量,一旦賦值初始化,遍不能修改
-
引入http模塊
-
創建server,request爲發送的請求,response爲返回的數據
-
response.write(‘pachong’);屏幕打印
實質上是node幫我們創建的HTML標籤 -
response.end();讓響應的代碼結束(不可缺)
完整代碼
指定9000端口
const http = require('http'); http.createServer((request,response)=>{ response.write('pachong'); response.end(); }).listen(9000);