programlearned
  • Introduction
  • js 筆記
    • Hammer.js 應用
  • node 筆記
    • 安裝與開始
    • exports 的應用
    • http 模組知識
    • Express 開始
      • 載入靜態檔案(image,css,js)
      • ejs 的使用
      • ejs layout的使用
      • ejs include的使用
      • ejs-form 的使用
      • ejs-ajax 的使用
      • route 的整理使用
    • 參考資料
  • vue 筆記
    • 安裝與開始
    • 基礎知識
      • 創建vue與輸出
      • v-bind 綁訂應用
      • v-for 與 v-if
      • v-on
      • v-class
      • 計算功能函數
      • 表單資料綁定
      • TodoList製作
    • 參考資料
  • Bootstrap 筆記
    • 相關資源網站
    • 安裝與開始
    • CSS 基礎知識
    • 容器container 應用
    • 網格系統 應用
      • 斷點
      • 版本斷點比較
      • 欄位排序
      • 欄位推移
      • 巢狀欄位
      • Flexbox 方向性
    • 間隔工具
    • 按鈕(button)
    • 不同的呈現(display)方式
    • 容器對齊方式
    • 文字(背景顏色)對齊與樣式
    • 導覽列應用
    • 參考資源
  • gitbook 製作與離線版
Powered by GitBook
On this page

Was this helpful?

  1. node 筆記

http 模組知識

創建檔案

  • 於根目錄創建 http.js

  • http.js :

var http = require("http");
http.createServer(function(require,response){
    response.writeHead(200,{"Content-Type":"text/plain"});
    response.write("hello world");
    response.end();
}).listen(8080);
  • 說明 :

    • 使用 require("http") 引入http 模塊

    • 使用 http.createServer() 可製作出server來傳遞資料

    • 利用 .listen(8080) 監聽 port 8080

    • 使用 response.writeHead() 設定傳送資料格式與表頭設定

      • 200 : 傳送正確

      • 404 : 傳送失敗(路徑錯誤)

      • 500 : 程式內部錯誤

      • text/plain : 文字訊息

      • text/html : 網頁文本

    • 使用 response.write("hello world") 設定在網頁上想顯示的資料

    • 使用 console.log(content.title) 得到想要的資料

  • 執行 node http.js即可在終端機看到成果

Previousexports 的應用NextExpress 開始

Last updated 6 years ago

Was this helpful?