当前位置:网站首页>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)
})
边栏推荐
- asp.net core JWT传递
- AKK菌——下一代有益菌
- Adobe Photoshop (PS) - script development - remove file bloated script
- Coefficient of variation method matlab code [easy to understand]
- 攻防演练中的防泄露全家福
- How to run jenkins build, in multiple servers with ssh-key
- 1-1 数据库的基本概念
- 1-18 创建最基本的express服务器&创建路由的API模块
- The 16th Heilongjiang Provincial Collegiate Programming Contest
- 1-13 express监听GET和POST请求&处理请求
猜你喜欢

文本识别-SVTR论文解读

Ten security measures against unauthorized access attacks

Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test

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

Icml2022 | utility theory of sequential decision making

Double solid histogram / double y-axis

SQL server extracts pure numbers from strings

Dm8: generate DM AWR Report

Text recognition svtr paper interpretation

Reading notes of Clickhouse principle analysis and Application Practice (2)
随机推荐
的撒啊苏丹看老司机
Electronic scheme development - Intelligent rope skipping scheme
做一个 Scrollbar 的思考
SQL server extracts pure numbers from strings
.netcore redis GEO类型
Adobe-Photoshop(PS)-脚本开发-去除文件臃肿脚本
笔记【JUC包以及Future介绍】
1-13 express监听GET和POST请求&处理请求
个人开发的渗透测试工具Satania
What about degradation of text generation model? Simctg tells you the answer
1-7 Path路径模块
12345
用yml文件进行conda迁移环境时的报错小结
申请Vector 总线协议彩图壁纸挂画,非常棒哦!
ClickHouse distributed表引擎
To the Sultanate of Anderson
Icml2022 | utility theory of sequential decision making
测试媒资缓存问题
Et la dégradation du modèle de génération de texte? Simctg vous donne la réponse
文本生成模型退化怎么办?SimCTG 告诉你答案