当前位置:网站首页>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
边栏推荐
- Huawei device command
- Taylor series fast Fourier transform (FFT)
- 【mysql】游标的基本使用
- SAP UI5 框架的 manifest.json
- Aike AI frontier promotion (7.6)
- Variable star --- article module (1)
- Reference frame generation based on deep learning
- Distributed ID
- 面试官:Redis中有序集合的内部实现方式是什么?
- 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
猜你喜欢

1_ Introduction to go language

What is the problem with the SQL group by statement

967- letter combination of telephone number

新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
![[wechat applet] operation mechanism and update mechanism](/img/cf/58a62a7134ff5e9f8d2f91aa24c7ac.png)
[wechat applet] operation mechanism and update mechanism

3D人脸重建:从基础知识到识别/重建方法!

KDD 2022 | 通过知识增强的提示学习实现统一的对话式推荐

The biggest pain point of traffic management - the resource utilization rate cannot go up

Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software

Common English vocabulary that every programmer must master (recommended Collection)
随机推荐
如何实现常见框架
el-table表格——获取单击的是第几行和第几列 & 表格排序之el-table与sort-change、el-table-column与sort-method & 清除排序-clearSort
Mtcnn face detection
Build your own application based on Google's open source tensorflow object detection API video object recognition system (IV)
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
过程化sql在定义变量上与c语言中的变量定义有什么区别
Dynamically switch data sources
Study notes of grain Mall - phase I: Project Introduction
Database - how to get familiar with hundreds of tables of the project -navicat these unique skills, have you got it? (exclusive experience)
2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
Detailed explanation of knowledge map construction process steps
Swagger UI tutorial API document artifact
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
Is it safe to open an account in flush? Which securities company is good at opening an account? Low handling charges
None of the strongest kings in the monitoring industry!
Reinforcement learning - learning notes 5 | alphago
PHP saves session data to MySQL database
强化学习-学习笔记5 | AlphaGo
7、数据权限注解
【微信小程序】運行機制和更新機制