//1.引入express框架 (url/querystring/path/fs/http等)
const express = require(“express”)
//2.创建web服务器
const app = express()
//3.监听端口
app.listen(3000,“localhost”,()=>{
console.log(“端口3000正在监听着哦…”)
})
//4.资源托管 (http://localhost:3000的时候,内部会自动的找到静态资源www目录下的index.html)
app.use(express.static("./www"))
//5.处理接口响应
app.get("/api/goods",(req,res)=>{
console.log(“处理了goods接口了哦…”)
res.end()
})
aaa.json:
{
“name”: “express232”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“start”:“nodemon index.js”
},
“keywords”: [],
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“express”: “^4.17.1”
}
}