Skip to content

Instantly share code, notes, and snippets.

@prankush-tech
Created August 11, 2022 07:41
Show Gist options
  • Save prankush-tech/62c545e2da1a7f750801450fa65c8e62 to your computer and use it in GitHub Desktop.
Save prankush-tech/62c545e2da1a7f750801450fa65c8e62 to your computer and use it in GitHub Desktop.

Revisions

  1. prankush-tech created this gist Aug 11, 2022.
    27 changes: 27 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HOME PAGE</title>
    </head>

    <body>

    <div class="homepage">
    <h1 class="text">THIS IS A HOME PAGE</h1>
    </div>
    <div class="list">
    <ui>
    <li>About</li>
    <li>Services</li>
    <li>Contact me</li>
    <li>home</li>
    </ui>
    </div>

    </body>

    </html>
    43 changes: 43 additions & 0 deletions server.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    const http = require('http');
    const port = 2000
    hostname= "localhost"
    const fs = require('fs')



    const home = fs.readFileSync("./index.html", "utf8")



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

    if(req.url === "/")
    {
    return res.end(home)
    }
    if(req.url === "/about")
    {
    return res.end("<h1>About Page</h1>")
    }
    if(req.url === "/contact")
    {
    return res.end("<h1>contact Page</h1>")
    }
    if(req.url === "/services")
    {
    return res.end("<h1>services Page</h1>")
    }
    if(req.url === "/help")
    {
    return res.end("<h1>help Page</h1>")
    }
    else
    {
    return res.end("<h1>404 JIHAD OCCURED</h1>")
    }
    })

    server.listen(port,"localhost",()=>
    {
    console.log(`Server is listening on port http://${hostname}:${port}`)
    })