create port in node js

technical talkiess
0

 const http = require('http');

const hostname = '127.0.0.1';

const port = 3000;

const server = http.createServer((req, res) => {

  res.statusCode = 200;

//   ye wala plain text ke use hota hai

//   res.setHeader('Content-Type', 'text/plain');

// html ke use hota hai

  res.setHeader('Content-Type', 'text/html');

//   ye page me serve hoga

//   res.end('Hello World');

  res.end(`<!DOCTYPE html>

  <html lang="en">

  <head>

      <meta charset="UTF-8">

      <meta name="viewport" content="width=device-width, initial-scale=1.0">

      <title>media query in css </title>

  </head>

  <style>

      .box{

          display: none;

          background-color: red;

          font-size: 40px;

          color: white;

      }

      @media only screen and (min-width:300px) and (max-width:500px) {

          #box-1{

              display: block;

              color: black;

              background-color: yellow;

          }

      }

      @media only screen and (min-width:500px) and (max-width:800px) {

          #box-2{

              display: block;

              color: black;

              background-color: green;

          }

      }

      @media only screen and (min-width:800px) and (max-width:1200px) {

          #box-3{

              display: block;

              color: black;

              background-color: greenyellow;

          }

      }

      @media only screen and (min-width:1200px){

          #box-4{

              display: block;

              color: black;

              background-color: pink;

          }

      }

  </style>

  <body>

      <div class="container">

          <div class="box" id="box-1">This is first box</div>

          <div class="box" id="box-2">This is Second box</div>

          <div class="box" id="box-3">This is Third box</div>

          <div class="box" id="box-4">This is four box</div>

      </div>

     

  </body>

  </html>`);

});

server.listen(port, hostname, () => {

  console.log(`Server running at http://${hostname}:${port}/`);

});


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)