سلام. ممنون از بیان شیوای استاد گرامی.
در قسمت 17 من تست کردم با استفاده از بک تیک میشه کدهای html چند خطی نوشت. با اجازه کدهاش رو میگذارم کسی خواست استفاده کنه.
const http = require('http');
const myList = [1, 2, 3, 4 ,5];
http.createServer((req, res)=>{
const {url , method , headers} = req;
res.setHeader("Content-Type" , "text/html");
res.write(`<html>
<head>
<title>My yest</title>
<style>
.txt-red{
color:red;
}
.txt-green{
color:green;
}
.txt-bold{
font-weight:bold;
}
.p-l-25{
padding-left: 50px;
}
.line-h{
line-height:1.7;
}
</style>
</head>
<body>
<h1>J.Mehdinia</h1>
<p class='txt-green'>
This is my first paragraph. The request method and url are: ${method} , ${url}
</p>
<p class='line-h'>
This is my second paragraph. ${JSON.stringify(headers)}
</p>
<p class='txt-bold p-l-25'>
<span class='txt-red'>
The items of [1,2,3] list are:
</span>
<br><br>
<span>
${myList.map((el , index)=>`Item ${index}: ${el}`).join("<br>")}
</span>
</p>
</body>
</html>`);
res.end();
}).listen(3000);
سلام دوست من
خیلی ممنونم