当前位置:网站首页>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 solves the problem of oversold inventory in the seckill system with high speed - redis transaction + optimistic lock mechanism
- Mock service Moco series (III) - redirection, regular expression, delay, template, event, sub module design
- UnitTest框架应用
- Go defer and recover simple notes
- 简述Synchronized以及锁升级
- Drawing PDF form (II) drawing excel form style in PDF through iText, setting Chinese font, watermark, logo, header and page number
- 简述聚簇索引、二级索引、索引下推
- 简述冒泡排序与快速排序
- C语言 libcurl交叉编译
- RestTemplate通过泛型实现POST、PUT、DELETE、GET、集合请求以及文件上传(可批量文件、可带参数)的统一封装(可打印日志)
猜你喜欢

IDEA集成SVN代码管理常用功能

Landmark buildings around the world

2022/7/23

What is an IP SSL certificate and how to apply for it?

BiSeNet v1

Take you to a preliminary understanding of multiparty secure computing (MPC)

Redistemplate solves the problem of oversold inventory in the seckill system with high speed - redis transaction + optimistic lock mechanism

越来越成熟的Rust,都应用了哪些场景呢?

关于云XR介绍,以及5G时代云化XR的发展机遇

Automated test Po design model
随机推荐
简述聚簇索引、二级索引、索引下推
Linux启动mysql报错
Good news! Ruiyun technology was awarded the member unit of 5g integrated application special committee of "sailing on the sea"
How many points did NPDP pass? How to pass with high scores?
Nineteen year old summary
SVN客户端(TortoiseSVN)安装及使用说明
Optimistic lock pessimistic lock applicable scenario
大话DevOps监控,团队如何选择监控工具?
Mock service Moco series (III) - redirection, regular expression, delay, template, event, sub module design
Which real-time gold trading platform is reliable and safe?
Several implementations of PHP to solve concurrency problems
C语言 libcurl交叉编译
Mock服务moco系列(一)- 简介、第一个Demo、Get请求、Post请求
简述Synchronized以及锁升级
New and malloc
UFT(QTP)-总结点与自动化测试框架
Mysql database common commands
Memory and packet buffer management of LwIP
Oracle使用impdp导入报错:ORA-39001: 参数值无效 ORA-39000: 转储文件说明错误 ORA-39088: 文件名不能包含路径说明
Mock service Moco series (I) - introduction, first demo, get request, post request