-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0faf0ec
commit ad0d4bd
Showing
6 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const http = require('http'); | ||
|
||
const server = http.createServer((req, res) => { | ||
console.log(req); | ||
}); | ||
|
||
const PORT = 3001; | ||
server.listen(PORT, () => { | ||
console.log(`Server running on address http://localhost:${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const http = require('http'); | ||
|
||
const server = http.createServer((req, res) => { | ||
console.log(req.url, req.method, req.headers); | ||
|
||
if (req.url === '/') { | ||
res.setHeader('Content-Type', 'text/html'); | ||
res.write('<html>'); | ||
res.write('<head><title>Complete Coding</title></head>'); | ||
res.write('<body><h1>Welcome to Home</h1></body>'); | ||
res.write('</html>'); | ||
return res.end(); | ||
} else if (req.url === '/products') { | ||
res.setHeader('Content-Type', 'text/html'); | ||
res.write('<html>'); | ||
res.write('<head><title>Complete Coding</title></head>'); | ||
res.write('<body><h1>Checkout our products</h1></body>'); | ||
res.write('</html>'); | ||
return res.end(); | ||
} | ||
res.setHeader('Content-Type', 'text/html'); | ||
res.write('<html>'); | ||
res.write('<head><title>Complete Coding</title></head>'); | ||
res.write('<body><h1>Like / Share / Subscribe</h1></body>'); | ||
res.write('</html>'); | ||
res.end(); | ||
}); | ||
|
||
const PORT = 3001; | ||
server.listen(PORT, () => { | ||
console.log(`Server running on address http://localhost:${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const http = require('http'); | ||
|
||
const server = http.createServer((req, res) => { | ||
console.log(req.url, req.method); | ||
if (req.url === '/home') { | ||
res.write('<h1>Welcome to Home</h1>'); | ||
return res.end(); | ||
} else if (req.url === '/men') { | ||
res.write('<h1>Welcome to Men</h1>'); | ||
return res.end(); | ||
} else if (req.url === '/women') { | ||
res.write('<h1>Welcome to Women</h1>'); | ||
return res.end(); | ||
} else if (req.url === '/kids') { | ||
res.write('<h1>Welcome to Kids</h1>'); | ||
return res.end(); | ||
} else if (req.url === '/cart') { | ||
res.write('<h1>Welcome to Cart</h1>'); | ||
return res.end(); | ||
} | ||
|
||
|
||
res.write(` | ||
<html lang="en"> | ||
<head> | ||
<title>Myntra</title> | ||
</head> | ||
<body> | ||
<head> | ||
<nav> | ||
<ul> | ||
<li><a href="/home">Home</a></li> | ||
<li><a href="/men">Men</a></li> | ||
<li><a href="/women">Women</a></li> | ||
<li><a href="/kids">Kids</a></li> | ||
<li><a href="/cart">Cart</a></li> | ||
</ul> | ||
</nav> | ||
</head> | ||
</body> | ||
</html> | ||
`); | ||
res.end(); | ||
}); | ||
|
||
server.listen(3001, () => { | ||
console.log('Server running on address http://localhost:3001'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Myntra</title> | ||
</head> | ||
<body> | ||
<head> | ||
<nav> | ||
<ul> | ||
<li><a href="/home">Home</a></li> | ||
<li><a href="/men">Men</a></li> | ||
<li><a href="/women">Women</a></li> | ||
<li><a href="/kids">Kids</a></li> | ||
<li><a href="/cart">🛒</a></li> | ||
</ul> | ||
</nav> | ||
</head> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const http = require('http'); | ||
const fs = require('fs'); | ||
|
||
const server = http.createServer((req, res) => { | ||
console.log(req.url, req.method, req.headers); | ||
|
||
if (req.url === '/') { | ||
res.setHeader('Content-Type', 'text/html'); | ||
res.write('<html>'); | ||
res.write('<head><title>Complete Coding</title></head>'); | ||
res.write('<body><h1>Enter Your Details:</h1>'); | ||
res.write('<form method="POST" action="submit-details">'); | ||
res.write('<input type="text" name="username" placeholder="Enter your name"><br>'); | ||
res.write('<input type="radio" name="gender" id="male" value="male" />'); | ||
res.write('<label for="male">Male</label>') | ||
res.write('<input type="radio" name="gender" id="female" value="female" />'); | ||
res.write('<label for="female">Female</label>'); | ||
res.write('<br><button type="submit">Submit</button>'); | ||
res.write('</form>'); | ||
res.write('</body>'); | ||
res.write('</html>'); | ||
return res.end(); | ||
|
||
} else if (req.url === '/submit-details' && | ||
req.method === 'POST') { | ||
fs.writeFileSync('user.txt', 'Prashant Jain'); | ||
res.statusCode = 302; | ||
res.setHeader('Location', '/'); | ||
return res.end(); | ||
} | ||
res.setHeader('Content-Type', 'text/html'); | ||
res.write('<html>'); | ||
res.write('<head><title>Complete Coding</title></head>'); | ||
res.write('<body><h1>Like / Share / Subscribe</h1></body>'); | ||
res.write('</html>'); | ||
res.end(); | ||
}); | ||
|
||
const PORT = 3001; | ||
server.listen(PORT, () => { | ||
console.log(`Server running on address http://localhost:${PORT}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Prashant Jain |