当前位置:网站首页>Express of nodejs simple example program
Express of nodejs simple example program
2022-07-25 18:05:00 【smile_ 5me】
First contact nodejs, You can only study hard , Don't say more first , Code up :
const express = require('express')
// Create a server
const app = express()
// Listen for client requests
// Only the request type of the client is get, also Request address is / When the root path ,
// Will call The handler specified later
app.get('/', (req, res) => {
// express in , It encapsulates better res.send Method
res.send(' Hello ,express The server !')
})
// Listen to the client post request , And the requested address is /adduser When ,
// Will call the processing function specified later
app.get('/adduser', (req, res) => {
console.log(req.query);
res.status(200).json({result:" Add success "});
})
app.post('/',function(req,res){
console.log(" Home page POST request ");
res.send('Hello POST');
})
// Start the server
app.listen(4444, () => {
console.log('express server running at http://127.0.0.1:4444')
})This is a very simple server , We open the browser , Input :http://127.0.0.1:4444/

So if you enter http://127.0.0.1:4444/adduser

Very understandable , Look at the code and see the effect of the actual demonstration , It's not hard to see , There are many good examples and explanations on the Internet , I won't explain more here , After all, I'm also a novice , I also hope that the boss with this knowledge can give me some opinions or suggestions after seeing this .
边栏推荐
- RedisTemplate解决高并发下秒杀系统库存超卖方案 — Redis事务+乐观锁机制
- PHP解决并发问题的几种实现
- Li Kai: the interesting and cutting-edge audio and video industry has always attracted me
- 有没有什么不起眼却挣钱的副业?
- Why is the index in [mysql] database implemented by b+ tree? Is hash table / red black tree /b tree feasible?
- Installation and operation instructions of SVN client (TortoiseSVN)
- 直击考点:PMP考试中常见敏捷知识点汇总
- What is an IP SSL certificate and how to apply for it?
- BiSeNet v1
- Which real-time gold trading platform is reliable and safe?
猜你喜欢

Auditing related notes

Li Kai: the interesting and cutting-edge audio and video industry has always attracted me

WPF implements user avatar selector

Redis source code and design analysis -- 16. AOF persistence mechanism

Good news! Ruiyun technology was awarded the member unit of 5g integrated application special committee of "sailing on the sea"

Landmark buildings around the world

云VR:虚拟现实专业化的下一步

What scenarios have rust, which is becoming more and more mature, applied?

Kendryte K210 在freertos上的lcd屏幕的使用

Redis source code and design analysis -- 15. RDB persistence mechanism
随机推荐
Go channel simple notes
RestTemplate通过泛型实现POST、PUT、DELETE、GET、集合请求以及文件上传(可批量文件、可带参数)的统一封装(可打印日志)
H5测试点(思维导图)
使用sqldeveloper连接mysql
SDLC 软件开发生命周期及模型
Redis source code and design analysis -- 16. AOF persistence mechanism
Automated test Po design model
Hcip first day experiment
Postman快速上手
Auditing相关注解
What are the advantages of real-time cloud rendering
MySQL page lock
TME2022校园招聘后台开发/运营开发/业务运维/应用开发笔试(I)编程题的一点自我分析
PageHelper can also be combined with lambda expressions to achieve concise paging encapsulation
Could not stop Cortex-M device! please check the JTAG cable的解决办法
Mock服务moco系列(二)- Json格式、File文件、Header、Cookie、解决中文乱码
testng执行顺序的3中控制方法
OSPF --- open shortest priority path protocol
Nineteen year old summary
Creation of unity Bezier curve