how to create node js page with html
///////////////command line install for express//////////////
////////////express.js//////////////
const express=require('express');
npm install express
const app=express('');
app.get('',(req,res)=>{
res.send('Hello,this is home page');
});
app.get('/about',(req,res)=>{
res.send('hello this is about page');
});
app.listen(5000);
run with command
PS C:\Users\dell\desktop\node-tut> node .\express.js
run in web
http://localhost:5000/about
var http = require('http'),
fs = require('fs');
fs.readFile('./index.html', function (err, html) {
if (err) {
throw err;
}
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
response.end();
}).listen(8000);
});
Comments
Post a Comment