-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (28 loc) · 937 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
const http = require('http');
const fs = require('fs');
var server = http.createServer((req, res)=>{
console.log(`request was made ${req.url}`);
if(req.url === '/index.css'){
fs.readFile(__dirname + '/index.css', (err, css) => {
res.writeHead(200, {'Content-Type': 'text/css'});
res.write(css);
res.end();
});
}
if(req.url === '/'){
fs.readFile(__dirname + '/index.html', (err, html) => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(html);
res.end();
});
}
if(req.url === "/favicon.ico"){
fs.readFile(__dirname + '/images/favicon.ico', (err, icon) => {
res.writeHead(200, {'Content-Type': 'image/x-icon'});
res.write(icon);
res.end();
});
}
});
server.listen(3000,'127.0.0.1');
console.log('Server running on : 127.0.0.1:3000');