express-新建-响应与请求

1.新建文件夹

2.初始化项目,导入express

yarn init -y
yarn add express

3.在文件夹中新建server.js

const express = require('express')

const app = express()


app.get('/',function(req,res){ //响应路由
  let responseObject={
    name:'qiuzhiqiuiu'
  }
  res.send('hello  express')
})

app.listen(3000,()=>console.log('app has running on prot 3000')) //在3000端口

4.导入nodemon

yarn global add nodemon

5.运行

nodemon server.js

 

posted on 2020-11-27 10:09  秃了头也不退休  阅读(116)  评论(0编辑  收藏  举报

导航