当前位置:网站首页>1-13 express listens to get and post requests & processes requests
1-13 express listens to get and post requests & processes requests
2022-06-30 21:30:00 【Endless pie】
express monitor GET request
// Import express
const express = require('express')
// establish web The server
const app = express()
// Listen to the client GET and POST request
//app.get Monitor client get request
app.get('/user',(req,res)=>{
// call express.send Method to the client corresponding object
res.send({name:'wang',gender:' male '})
})
//app.post Monitor client get request
app.post('/user',(req,res)=>{
// call express.send Method to the client corresponding object
res.send(' The request is successful ')
})
// start-up web The server
app.listen(80,()=>{
console.log('sever')
})
obtain URL Query parameters carried in
app.get('/',(req,res)=>{
// adopt req.query You can get the data sent by the client , Query parameters
// Be careful , By default req.query Is an empty object
console.log(req.query)
res.send(req.query)
})
obtain URL Dynamic parameters in
adopt req.params object . Access to URL in , adopt : Matching dynamic parameters
app.get('/user/:id',(req,res)=>{
//:id It's a dynamic parameter
//params The default is an empty object
// In it is stored through : Dynamically matched parameter values
let params = req.params
res.send(params)
})
边栏推荐
猜你喜欢

Icml2022 | utility theory of sequential decision making

《ClickHouse原理解析与应用实践》读书笔记(1)
测试媒资缓存问题

时空数据挖掘:综述

个人开发的渗透测试工具Satania

ArcGIS construction and release of simple road network data service and rest call test

Reading notes of Clickhouse principle analysis and Application Practice (2)

MySQL advanced 3

Iclr'22 spotlight | how to measure the amount of information in neural network weights?

《ClickHouse原理解析与应用实践》读书笔记(2)
随机推荐
How to move forward when facing confusion in scientific research? How to give full play to women's advantages in scientific research?
【无标题】
ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?
SQL server extracts pure numbers from strings
Oracle 数据库表结构 Excel 导出
Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
文本生成模型退化怎麼辦?SimCTG 告訴你答案
. NETCORE redis geo type
1-15 nodemon
The 16th Heilongjiang Provincial Collegiate Programming Contest
Arcmap|assign values to different categories of IDS with the field calculator
go搭建服务器基础
Ssh server configuration file parameter permitrootlogin introduction
文本生成模型退化怎么办?SimCTG 告诉你答案
Test medal 1234
ca i啊几次哦啊句iu家哦11111
Iclr'22 spotlight | how to measure the amount of information in neural network weights?
sdfsdf
clickhouse原生監控項,系統錶描述
NCAT detailed introduction (Reprint)