forked from fineanmol/Hacktoberfest2024
-
Notifications
You must be signed in to change notification settings - Fork 30
/
anuj4
28 lines (25 loc) · 765 Bytes
/
anuj4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const http = require('http');
const fs = require('fs');
const _ = require('lodash');
//// have to do something with html pages and server.js (Routing)
const server = http.createServer((req,res)=>{
console.log('request', req.url);
const num = _.random(20,32);
console.log(num);
res.setHeader('Content-Type','text/html');
// res.write('<title>loading</title>');
// res.write('<p>hello again</p>');
// res.write('<body></body>');
var int = null;
fs.readFile('../p1/index.html',(err,data)=>{
if(!err){
// res.write('data');
// res.end();
res.end(data);
}
else console.log(err.code)
});
})
server.listen('3000','localhost',()=>{
console.log('listenong...');
})