当前位置:网站首页>Nodejs tutorial expressjs article quick start

Nodejs tutorial expressjs article quick start

2022-07-06 21:09:00 Knowledge fatness

What is? Expressjs

Express It is used on the server side Web Application's Node.js frame .Express be based on Node.js Function building , It can provide simple and fast Web And mobile server solutions . It is an open source framework , from Node.js Community maintenance . stay Express Many other libraries have been built on , Many large technology companies are using Express.

Project environment construction

Suppose you have installed Node.js, Create a directory to save your application , And set it as your working directory .

mkdir myapp
cd myapp

Use this npm init Command to create a package.json file . About how package.json Working

npm init

Now install in the directory Express And save it in the dependency list . for example :

npm install express

Project source code

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Project operation

Run the application with the following command :

node index.js
原网站

版权声明
本文为[Knowledge fatness]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061251159339.html

随机推荐