Node.js
小于 1 分钟
Node.js
构建web服务器(express框架)
初始化
npm init -y
安装node的类型定义文件
npm i @types/node --save-dev
安装express
npm i express --save-dev
安装@types/express
npm install @types/express --save-dev
hello world
import express from 'express'
const app = express();
app.use("*",(req, res , next)=>{
res.status(200).set({'Content-Type':'html/text'}).end('<h1>hello world</h1>');
});
app.listen(4000,()=>{
console.log('https://localhost:4000');
});