NODE JS

How to use HTML in NODE JS || Display simple HTML

  • Neel Bhardwaj

  • 15-Jan-2022

  • 0 comments

  • 113

In this example i show to how to use only simple html code in NODE JS. 

in this example the important thing is to use the 

content-type:text/html

If u display the HTML.

EG:

var http = require('http');

const server = http.createServer((request,response)=>{

var data = "<html>

      <html>

       <head>

       <title></title>

</head>

<body>

<input type="text">

</body>

</html>";

 

response.writeHead(200,{'content-type':'text/html'});

response.write(data);

response.end();

});

server.listen(3000,()=> console.log("Server run"));

 

"Programming isn't about what you know,
it's about what you can figure out.”
Chris Pine

Neel Bhardwaj

A full stack developer. I have a Passion for Creating Clean, Beautiful, Interactive, Minimalistic, Responsive and User Friendly website, Developed by Modular, Scalable and Functional Code.

Recent comments

Leave a reply