export chat service listen host

This commit is contained in:
tursom 2024-04-28 11:19:15 +08:00
parent 19f92fec09
commit 6da58473d8

View File

@ -4,6 +4,7 @@ const http = require('http');
const {once} = require("node:events");
const server = http.createServer(async (req, res) => {
try {
let body = '';
req.on('data', chunk => {
body += chunk.toString(); // 将Buffer转换为字符串
@ -29,8 +30,11 @@ const server = http.createServer(async (req, res) => {
res.setHeader('Content-Type', 'text/plain');
res.end('Success\n');
})
} catch (e) {
console.error("An error occurred while processing the request: ", e);
}
});
server.listen(3000, '127.0.0.1', () => {
console.log('Server running at http://127.0.0.1:3000/');
server.listen(3000, '0.0.0.0', () => {
console.log('Server running at http://0.0.0.0:3000/');
});