創建一個 Web Server
- 建立專案資料夾與
all.js - require
http模組 - 撰寫
creatServer的 function
何謂 request 與 response ?
- request 請求: 當使用者讀取網站時會向伺服器發送請求,伺服器接收到使用者的相關資料
- response 回傳 : 收到 request 後回傳的資料
以下是範例程式碼:
1 | const http = require('http'); |
執行 node app.js 後開啟 http://localhost:8080就會看到 hello 囉!