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.

35 lines
792 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>
7 months ago
<h1>HTML2</h1>
7 months ago
</body>
</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.