node server.js运行js代码
const express = require("express")
const app = express()
app.get('/', function(req,res){//req是客户端的请求,res是响应
res.send([
{user:'tim'}
])
})
app.get('/about', function(req,res){
res.send([
{user:'tom'}
])
})
app.listen(8080, () => {
console.log('add!');
});
浏览器中输入localhost::8080和http://localhost:8080/about显示
如果需要实时修改js内容
使用nodemon server.js 语句在终端运行 ctrl+s后刷新网页即可显示