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.

26 lines
480 B

2 years ago
// 引入express
const express = require("express");
// 创建网站服务器
const app = express();
app.use((req,res,next)=>{
next()
})
app.get("/",(req,res)=>{
res.send("这里是根目录")
})
// app.use() 这里不能使用/,否则会匹配所有,和不写一样
// 自定义404
// 必须写在最后
app.use((req,res,next)=>{
res.send("请求页面不存在!")
})
// 开启服务器监听
app.listen(80);
console.log("服务器已开启")