I'm working through the tutorial in the beginner node book and I'm putting in this code.
var body = '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
</head>
<body>
<form action="/upload" method="post">
<textarea name="text" rows="20" cols="60"></textarea>
<input type="submit" value="Submit text"/>
</form>
</body>
</html>';
response.writeHead(200,{"Content-Type" : "text/plain"});
response.write(body);
response.end();
I've spaced it out, but I know I need to put it all on one line, when I do, the textarea does not appear, the html as written appears on screen.
I've spaced it out because I'm not sure if the html is correct.
What's going wrong?
Try changing this line:
response.writeHead(200,{"Content-Type" : "text/plain"});
To:
response.writeHead(200,{"Content-Type" : "text/html"});
(You want the browser to interpret it as html, not plain text.)