当前位置:网站首页>Express builds a simple local background (1)
Express builds a simple local background (1)
2022-07-28 09:29:00 【Front end program】
List of articles
Tips : This article will explain how to build a simple background program , Write a get Interface of type .
List of articles
Preface
Tops:1. When talking about problems with the backend partners today , I thought of building a simple local server .
2. I have studied before Node The server , I can't remember when I suddenly want to build a server , What is the specific process , Just write this article !!!!!!!!
3. It is convenient for me to review when I need it in the future !!!!!!
Tips : Follow up Node backstage Api It will also be constantly updated !!!!!!!
One 、express What is it? ?
Express It's based on Node.js Minimalism of the platform 、 agile web Application development framework , It provides a powerful set of features , Help you create a variety of Web And mobile applications .
tips: For front-end developers , It can satisfy us to build local servers , Don't study java You can operate the database . Make front-end students know more about the work of back-end students
Two 、express Steps to set up the server
1. Initialization and installation
// Execute the following command: Initialization file
// If you don't need to add the details of the project , Just go all the way back
npm init
The initialization is shown in the figure below :

// install express( Add... According to your own needs -S It's fine too Add -D)
npm i express
install express Here's the picture

2. Use express The construction steps are as follows :
The code is as follows :
//1. Import... In a file express
var express =require('express')
//2. Register an instance app
var app =express()
//3. Register a listening interface
app.listen(3000,()=>{
console.log("Server is strat !!!!!!");
})
The steps are as follows :

3、 ... and . Browser test results
1. There is no return result of the default interface

2. Added default interface results
Interface codeding Here's the picture :
// Write a get Requested interface
app.get('/',(req,res)=>{
res.json(`1231313`)
})

Browser result graph

边栏推荐
- Oracle-11gr2 default system job
- QT basic hand training applet - simple calculator design (with source code, analysis)
- How to use gbase C API in multithreaded environment?
- opencv4.60版本安装和配置
- 股指期货开户的条件和流程
- ES6 let and Const
- LeetCode_ 406_ Rebuild the queue based on height
- Regular expressions for positive and negative values
- MySQL 8.0.30 GA
- F - jealous two-dimensional reverse order pair
猜你喜欢

OpenShift 4 - 使用 VerticalPodAutoscaler 优化应用资源 Request 和 Limit
![Magic brace- [group theory] [Burnside lemma] [matrix fast power]](/img/cf/606d1bc7cd877771afbdd7640b718c.png)
Magic brace- [group theory] [Burnside lemma] [matrix fast power]

Technology sharing | quick intercom integrated dispatching system

股指期货开户的条件和流程

MQTT. JS introductory tutorial: learning notes

Problems encountered in upgrading golang to version 1.18.4

Promise实例如何解决地狱回调

2022 safety officer-b certificate examination simulated 100 questions and answers

【592. 分数加减运算】

RGB-T追踪——【多模态融合】Visible-Thermal UAV Tracking: A Large-Scale Benchmark and New Baseline
随机推荐
Personal blog applet
[附下载]推荐几款暴力破解和字典生成的工具
【解决】ERROR in [eslint] ESLint is not a constructor
Deconstruction assignment of ES6 variables
Talk to the father of MySQL: code completion at one time is a good programmer
Leetcode 452. minimum number of arrows to burst balloons (medium)
51单片机存储篇:EEPROM(I2C)
2022牛客多校第一场补题
7 C控制语句:分支和跳转
Modify virtual machine IP address
Hexadecimal representation of negative numbers
QT基础练手小程序-简单计算器设计(附带源码,解析)
IT行业数据与应用关系的变迁
【杂谈】程序员的发展最需要两点能力
[multithreading] non atomic agreement of long and double
[solution] error in [eslint] eslint is not a constructor
Starfish Os打造的元宇宙生态,跟MetaBell的合作只是开始
Get started quickly with flask (I) understand the framework flask, project structure and development environment
数据库核心体系
C signed and unsigned byte variables