当前位置:网站首页>Create a server with node
Create a server with node
2022-06-21 17:30:00 【Yu'an_ ZhangDe】
1、 Import http modular
// 1、 Import http modular
const http = require('http')
2、 establish web Server instance
// 2、 establish web Server instance
const server = http.createServer()
3、 Bind to the server instance request event , Listen for client requests
// 3、 Bind to the server request event
server.on('request',(req,res)=>{
// req.url Get request address The default is /
const url = req.url
console.log(url);
// req.method How to get the request get/post
const method = req.method
console.log(method);
// res.end() The server responds to the client Chinese is not supported
res.end('Hello world!')
})4、 Start the server
// 4 、 Start the server
server.listen(80,()=>{
console.log('server running at http://localhost');
})Operation result diagram

Installation configuration NodeJs Environmental Science
If you want to realize the above functions , First you need to install the configuration NodeJs Environmental Science , I put the link here , Please go to the rookie tutorial to see the specific tutorial , I won't go into details here .
Node.js Installation configuration | Novice tutorial (runoob.com)
边栏推荐
- The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool
- Mqtt of NLog custom target
- Android kotlin 类委托 by,by lazy关键
- Kotlin DSL build
- Garbage collector
- Notice on the third national operation research / data, model and decision-making course teaching seminar in 2022
- Implementation of decode function in GP
- The next stop of Intelligent Manufacturing: cloud native + edge computing two wheel drive
- Sword finger offer II 089 House theft / Sword finger offer II 090 Ring house theft
- fs.readFile() 和 fs.writeFile()
猜你喜欢
随机推荐
牛客网:大数加法
面向流动人口管理的人脸验证系统设计及实现 论文+答辩PPT+项目工程文件
[MySQL learning notes 18] constraints
data type
【mysql学习笔记14】DQL语句执行顺序
从北京“润”到芝加哥,工程师宝玉“滋润”成长的秘诀
Design a print function to print the whole tree
xlrd寻找指定内容所在行与行内容
「运维有小邓」Active Directory批量修改用户
Android kotlin泛型知识点梳理
MATLAB实现的基于对称TSP问题研究
变量与指针
线段树&树状数组模板
20 pyGame module to make a jumping ball game
Design and implementation of face verification system for floating population management
Use picgo core and Alibaba cloud to automatically upload typera pictures
[MySQL learning notes 11] sort query
How to connect the Internet - FTTH
Stack growth direction and memory growth direction
go corn定时任务简单应用









