-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (36 loc) · 991 Bytes
/
index.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const operations=require('./index2');
const http=require('http'); //require client and server
const fs=require('fs'); // files reader
const express=require('express'); //express framework
port=8000; //local server
function requestHandler(req,res)
{
res.writeHead(200,{'content-type':'text/html'}); // making reponse machine and content is html
let files;
switch(req.url)
{
case '/':
files='./index.html';
break;
}
fs.readFile(files,function(err,data) // read html file
{
if(err)
{
console.log('error',err);
return res.end('<h1>Error</h1>'); // writting html code
}
return res.end(data); // write html data
});
}
const server=http.createServer(requestHandler); //server will activate for request Handler
server.listen(port,function(err) //server listen to port and check it
{
if(err)
{
console.log("error",err);
return;
}
console.log("running",port);
});
console.log(operations.add(2,19));