当前位置:网站首页>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
边栏推荐
- How to turn a multi digit number into a digital list
- Introduction to the use of SAP Fiori application index tool and SAP Fiori tools
- What is the problem with the SQL group by statement
- 【论文解读】用于白内障分级/分类的机器学习技术
- Database - how to get familiar with hundreds of tables of the project -navicat these unique skills, have you got it? (exclusive experience)
- HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
- Laravel notes - add the function of locking accounts after 5 login failures in user-defined login (improve system security)
- 1500万员工轻松管理,云原生数据库GaussDB让HR办公更高效
- OSPF multi zone configuration
- 【微信小程序】运行机制和更新机制
猜你喜欢
PHP online examination system version 4.0 source code computer + mobile terminal
Introduction to the use of SAP Fiori application index tool and SAP Fiori tools
Data Lake (VIII): Iceberg data storage format
Study notes of grain Mall - phase I: Project Introduction
Distributed ID
【mysql】触发器
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
Activiti global process monitors activitieventlistener to monitor different types of events, which is very convenient without configuring task monitoring in acitivit
Why do job hopping take more than promotion?
KDD 2022 | 通过知识增强的提示学习实现统一的对话式推荐
随机推荐
KDD 2022 | realize unified conversational recommendation through knowledge enhanced prompt learning
【微信小程序】运行机制和更新机制
R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
字符串的使用方法之startwith()-以XX开头、endsWith()-以XX结尾、trim()-删除两端空格
【mysql】触发器
【mysql】游标的基本使用
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Entity alignment two of knowledge map
Spark SQL chasing Wife Series (initial understanding)
for循环中break与continue的区别——break-完全结束循环 & continue-终止本次循环
(work record) March 11, 2020 to March 15, 2021
Math symbols in lists
[MySQL] basic use of cursor
Summary of different configurations of PHP Xdebug 3 and xdebug2
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
el-table表格——sortable排序 & 出现小数、%时排序错乱
什么是RDB和AOF
1500萬員工輕松管理,雲原生數據庫GaussDB讓HR辦公更高效
C language games - minesweeping