Express 基於Node.js平臺,快速、開放、極簡的web開發框架 Express特點 1. 他提供一系列強大的特性,幫助你創建各種web和移動設備應用2. 豐富的HTTP快捷方法和任意排列組合的Connect中間件,讓你創建健壯、友好的API變得即快速又簡單3. Express不對Node. ...
Express
基於Node.js平臺,快速、開放、極簡的web開發框架
Express特點
1. 他提供一系列強大的特性,幫助你創建各種web和移動設備應用
2. 豐富的HTTP快捷方法和任意排列組合的Connect中間件,讓你創建健壯、友好的API變得即快速又簡單
3. Express不對Node.js已有的特性進行二次抽象,我們只是在它之上擴展了web應用所需的基本功能
安裝
npm install express --save
基本使用
const express = require('express');//引入 let app = new express();//實例化 app.get('/',(req,res)=>{ res.send('你好!express') //send為express提供的 //這裡的send相當於res.write()+res.end() }) //http://localhost:3000/product?name=xiaoming&age=10 app.get('/product',(req,res)=>{ console.log(req.query); //{ name: 'xiaoming', age: '10' } //query:拿到get請求的參數 res.send('/product') }) app.listen(3000,()=>{ console.log('Running...') })