You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
839 B

7 months ago
const http = require('http');
const server = http.createServer(async (req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
try {
await new Promise(resolve => setTimeout(resolve, 1000));
// Простой HTML-код
const htmlContent = `
<!DOCTYPE html>
<html>
<head>
<title>simple_server</title>
</head>
<body>
<h1>HTML</h1>
</body>
</html>
`;
// Отправка HTML клиенту
res.end(htmlContent);
} catch (error) {
console.error('Ошибка:', error.message);
res.writeHead(500, {'Content-Type': 'text/plain'});
res.end('Internal Server Error');
}
});
const port = 3000;
server.listen(port, () => {
console.log(`Server started on port ${port}`);
});

Powered by TurnKey Linux.