当前位置:网站首页>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 .
边栏推荐
- 国际权威认可!OceanBase入选Forrester Translytical数据平台报告
- 「行话」| 用DevOps高效交付游戏,是种什么体验?
- UFT(QTP)-总结点与自动化测试框架
- Could not stop Cortex-M device! please check the JTAG cable的解决办法
- C LINQ de Duplication & de duplication sum
- 图的相关操作
- Mock service Moco series (I) - introduction, first demo, get request, post request
- How to choose digital twin visualization platform
- Joseph Ring problem
- UnitTest框架应用
猜你喜欢

使用sqldeveloper连接mysql

Why the future of digitalization depends on 3D real-time rendering

3DCAT v2.1.3新版本发布,这三大功能更新你不容错过!

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

OSPF --- open shortest priority path protocol
![Why is the index in [mysql] database implemented by b+ tree? Is hash table / red black tree /b tree feasible?](/img/1f/a2d50ec6bc97d52c1e7566a42e564b.png)
Why is the index in [mysql] database implemented by b+ tree? Is hash table / red black tree /b tree feasible?

SLA 、SLO & SLI

SLA 、SLO & SLI

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

RedisTemplate解决高并发下秒杀系统库存超卖方案 — Redis事务+乐观锁机制
随机推荐
Drawing PDF form (II) drawing excel form style in PDF through iText, setting Chinese font, watermark, logo, header and page number
MATLAB中join函数使用
tkinter GUI版通信录管理系统
PageHelper can also be combined with lambda expressions to achieve concise paging encapsulation
Go channel simple notes
Lwip之内存与包缓冲管理
Notes on Flickr's dataset
IDEA集成SVN代码管理常用功能
OV7725 yuv 640*[email protected] 配置文件
Redis source code and design analysis -- 15. RDB persistence mechanism
STM8S003F3 内部flash调试
排序还需要了解的信息以及链表
OSPF --- open shortest priority path protocol
Good news! Ruiyun technology was awarded the member unit of 5g integrated application special committee of "sailing on the sea"
Several implementations of PHP to solve concurrency problems
Postman get started quickly
MySQL数据库常用命令
Mock服务moco系列(二)- Json格式、File文件、Header、Cookie、解决中文乱码
Why the future of digitalization depends on 3D real-time rendering
Redis source code and design analysis -- 17. Redis event processing