当前位置:网站首页>Nodejs教程之Expressjs一篇文章快速入门
Nodejs教程之Expressjs一篇文章快速入门
2022-07-06 12:51:00 【知识大胖】
什么是Expressjs
Express 是用于服务器端 Web 应用程序的 Node.js 框架。Express 基于 Node.js 功能构建,可提供简单快速的 Web 和移动服务器解决方案。它是开源框架,由 Node.js 社区维护。在 Express 上构建了许多其他库,许多大型科技公司正在其后端服务中使用 Express。
项目环境建设
假设您已经安装了Node.js,创建一个目录来保存您的应用程序,并将其设为您的工作目录。
mkdir myapp
cd myapp
使用该npm init命令为您的应用程序创建一个package.json文件。有关如何package.json工作的
npm init
现在在目录中安装 Express并将其保存在依赖项列表中。例如:
npm install express
项目源码
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}`)
})
项目运行
以下命令运行应用程序:
node index.js
边栏推荐
- 2022 fields Award Announced! The first Korean Xu Long'er was on the list, and four post-80s women won the prize. Ukrainian female mathematicians became the only two women to win the prize in history
- document.write()的用法-写入文本——修改样式、位置控制
- Select data Column subset in table R [duplicate] - select subset of columns in data table R [duplicate]
- 15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
- Math symbols in lists
- Common English vocabulary that every programmer must master (recommended Collection)
- el-table表格——sortable排序 & 出现小数、%时排序错乱
- 监控界的最强王者,没有之一!
- 拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
- 快过年了,心也懒了
猜你喜欢
Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an
Redis insert data garbled solution
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
Comprehensive evaluation and recommendation of the most comprehensive knowledge base management tools in the whole network: flowus, baklib, jiandaoyun, ones wiki, pingcode, seed, mebox, Yifang cloud,
OneNote in-depth evaluation: using resources, plug-ins, templates
愛可可AI前沿推介(7.6)
[wechat applet] operation mechanism and update mechanism
use. Net analysis Net talent challenge participation
【深度学习】PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
Spark SQL chasing Wife Series (initial understanding)
随机推荐
New database, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, Feishu multidimensional table, heipayun, Zhixin information, YuQue
(work record) March 11, 2020 to March 15, 2021
Pat 1085 perfect sequence (25 points) perfect sequence
Notes - detailed steps of training, testing and verification of yolo-v4-tiny source code
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
#yyds干货盘点#重新梳理箭头函数的this
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
use. Net drives the OLED display of Jetson nano
Activiti global process monitors activitieventlistener to monitor different types of events, which is very convenient without configuring task monitoring in acitivit
OAI 5G NR+USRP B210安装搭建
Spark SQL chasing Wife Series (initial understanding)
Common English vocabulary that every programmer must master (recommended Collection)
Reflection operation exercise
3D人脸重建:从基础知识到识别/重建方法!
【论文解读】用于白内障分级/分类的机器学习技术
Distributed ID
Why do job hopping take more than promotion?
15 millions d'employés sont faciles à gérer et la base de données native du cloud gaussdb rend le Bureau des RH plus efficace
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
Pycharm remote execution