Nodejs之HelloWord & Hello-Http

作者 劲松

示例1:代码HelloWord ,新建Hello-Http.js文件

console.log("Hello")

示例2:Hello-Http,新建Hello-Http.js文件

const http = require('node:http');

const hostname = '127.0.0.1';

const port = 3000;

const server = http.createServer((req, res) => {

res.statusCode = 200;

res.setHeader('Content-Type', 'text/plain');

res.end('Hello, World!\n');

});

server.listen(port, hostname, () => {

console.log(`Server running at http://${hostname}:${port}/`);

});

验证:

hello-http验证结果如图:

转自 作者 劲松

相关推荐
报错小能手4 小时前
计算机网络自顶向下方法55——无线网移动网 移动性管理
网络·计算机网络
jun_bai13 小时前
python写的文件备份网盘程序
运维·服务器·网络
爱吃牛肉的大老虎13 小时前
网络传输架构之gRPC讲解
网络·架构
Warren9813 小时前
Python自动化测试全栈面试
服务器·网络·数据库·mysql·ubuntu·面试·职场和发展
云飞云共享云桌面14 小时前
无需配置传统电脑——智能装备工厂10个SolidWorks共享一台工作站
运维·服务器·前端·网络·算法·电脑
骆驼102415 小时前
手机热点和无线路由器在 IPv6 工作模式上的区别
网络·ipv6
jenchoi41316 小时前
【2025-11-23】软件供应链安全日报:最新漏洞预警与投毒预警情报汇总
网络·数据库·安全·web安全·网络安全
独行soc17 小时前
2025年渗透测试面试题总结-258(题目+回答)
网络·python·安全·web安全·渗透测试·安全狮
AI绘画小3318 小时前
网络安全(黑客技术)—2025自学手册
网络·安全·web安全·网络安全·渗透测试
国服第二切图仔18 小时前
Electron for 鸿蒙PC实战案例Gitcode口袋工具之HTTP请求封装的技术实现与设计解析
http·electron·gitcode