如何在 nodejs 中创建一个返回 Hello World 的简单服务器?
2023-06-19 08:55
nodejs
136
0
0
0
标题录入
封面图
答: 使用 Node.js 的原生 http 模块来创建一个简单的服务器: // 引入 `http` 模块 const http = require('http'); // 创建一个 HTTP 服务器 const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello Worldn'); }); // 监听服务器端口 server.listen(3000); console.log('server listening on port 3000');
上一篇:
我们如何在nodejs中使用async await ?
下一篇:
nodejs 如何工作的 ?
标题录入,一次不能超过6条
怎么证明自己的选择是对的?
T:0.006288s,M:244.49 KB
返回顶部
留言
留言
评论