const http = require('http');
http.createServer((req, res) => {
switch(req.method) {
case "GET":
res.writeHead(200, {
"Content-Type": "text/html;charset=utf-8"
});
res.end(`<form method="post" action="/=">
<input type="text" name="myName">
<input type="submit" name="submit" value="Отправить">
</form>`);
break;
case "POST":
req.on('data', data => {
res.writeHead(200, {
"Content-Type": "text/html;charset=utf-8"
});
req.on('end', () => {
res.end("Строка post запроса: " + data.toString());
});
});
break;
}
}).listen(3000, () => {
console.log("Server is running");
});
Такая проблема только с кириллицей