1-2 web框架(The web framework)
web框架
{
"name":"socket-chat-example",
"version":"0.0.1",
"description":"my first socket.io app",
"dependencies":{}
} npm install --save express@4.15.2 #这里不建议指定版本
#npm install --save express//en 版本提供的例子
const app = require('express')()
const http=require('http').Server(app)
app.get('/',(req,res)=>{
res.send('<h1>Hello world</h1>')
})
http.listen(3000,()=>{
console.log('listening on *:3000')
})
//个人简写如下:
const express = require('express')
const app = express()
app.get('/',(req,res)=>{
res.send('<h1>Hello world</h1>')
})
app.listen(3000,()=>{
console.log('listening on *:3000')
})

Last updated
Was this helpful?