You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
448 B
21 lines
448 B
// 引入express
|
|
const express = require("express");
|
|
|
|
// 创建网站服务器
|
|
const app = express();
|
|
|
|
// 路由
|
|
app.get("/",(req,res)=>{
|
|
res.send("Hello Node For Express");
|
|
// send替代了end
|
|
// 1.自动检测响应内容类型
|
|
// 2.自动设置HTTP状态吗
|
|
// 3.自动设置响应类型和编码
|
|
});
|
|
|
|
app.get("/list",(req,res)=>{
|
|
res.send({name:"何小龙",sex:"男"})
|
|
})
|
|
|
|
// 开启服务器监听
|
|
app.listen(80) |