forked from FRUHD/NOSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
44 lines (35 loc) · 1.16 KB
/
server.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
const http = require('http');
const fs = require('fs');
const url = require('url');
const querystring = require('querystring');
const server = http.createServer((req, res) => {
const readWrite = (file, contentType) => {
fs.readFile(file, function(err, data) {
res.writeHead(200, {'Content-Type': contentType});
res.write(data);
res.end();
});
}
const page = url.parse(req.url).pathname;
const params = querystring.parse(url.parse(req.url).query);
console.log(page);
if (page == '/') {
readWrite('index.html','text/html')
} else if (page == '/css/style.css') {
fs.readFile('css/style.css', function(err, data) {
res.write(data);
res.end();
})
} else if (page == '/js/main.js') {
readWrite('js/main.js', 'text/javascript')
} else {
return;
}
// Nose picker click event will randomize 3 buttons (main.js file)
// generate color math floor to 1 - 3 to equal three prepicked rgb values
// buttons will do nothing
// After randomization buttons will each have a color assigned
// Button click with access DOM and change background color
// Yay! Success?
server.listen(8000);
})