NODE.JS_pracset_4

 node js practice set 4 code by me=>

const http = require('http');

const server = http.createServer((req,res)=>{
    if(req.url === '/home'){
        res.setHeader('Content-Type','text/html');
        res.write('<html>');
        res.write('<head></head>');
        res.write('<body><h1>Welcome to HOME</h1></body>')
        res.write('</html>');
        return res.end();
    }
    else if(req.url.toLowerCase() === '/men'){
        res.setHeader('Content-Type','text/html');
        res.write('<html>');
        res.write('<head></head>');
        res.write('<body><h1>Welcome to MENs Section</h1></body>');

        res.write('</html>');
        return res.end();


    }
    else if(req.url.toLowerCase() === '/women'){
        res.setHeader('Content-Type','text/html');
        res.write('<html>');
        res.write('<body><h1>Welcome to WOMENs Section</h1></body>');
   
        res.write('</html>');
        return res.end();

    }
    else if(req.url.toLowerCase() === '/kids'){
        res.setHeader('Content-Type','text/html');
        res.write('<html>');
        res.write('<body><h1>Welcome to KIDs Section</h1></body>');
   
        res.write('</html>');
        return res.end();

    }
    else if(req.url.toLowerCase() === '/cart'){
        res.setHeader('Content-Type','text/html');
        res.write('<html>');
        res.write('<body><h1>Welcome to CART Section</h1></body>');
   
        res.write('</html>');
        return res.end();

    }
    res.setHeader('Content-Type','text/html');
        res.write('<html>');
        res.write('<body><h1>Link Not Find!!TRY AGAIN!!:(</h1></body>');
   
        res.write('</html>');
        res.end();

});

const PORT = 3002;
server.listen(PORT,()=>{
    console.log(`Server is running at http://localhost:${PORT}`);
});

Comments

Popular posts from this blog

Blockchain Technology: Redefining Trust in the Digital Era

Essential - A clothing BRAND!!

FIRST PROJECT IN CPP(VECHILE PARKING MANAGEMENT SYSTEM!!)