forked from CobaltBlue-Team7/IoTProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.js
43 lines (40 loc) · 1.02 KB
/
button.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
var http = require('http');
var fs = require('fs');
var server = http.createServer(function (req, resp) {
//console.log(req.url);
var str = req.url.split('?');
//console.log(str[0], str[1]);
if (req.url == "/create") {
fs.readFile("./button.html", function (error, pgResp) {
if (error) {
resp.writeHead(404);
resp.write('Contents are not found');
}
else {
resp.writeHead(200, { 'Content-Type': 'text/html' });
resp.write(pgResp);
}
resp.end();
});
}
else if(str[0] =="/show_graph"){
fs.readFile("./button2.html", function (error, pgResp) {
if (error) {
resp.writeHead(404);
resp.write('Contents are not found');
}
else {
resp.writeHead(200, { 'Content-Type': 'text/html' });
resp.write(pgResp);
}
resp.end();
});
}
else {
resp.writeHead(200, { 'Content-Type': 'text/html' });
resp.write('<h1>Product Manager</h1><br /><br />To create product please enter: ' + req.url);
resp.end();
}
});
server.listen(5050);
console.log('Server Started listening on 5050');