forked from go4tech-au/cloud-internal-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
106 lines (106 loc) · 3.63 KB
/
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const cool = require('cool-ascii-faces');
const PORT = process.env.PORT || 5000;
const http = require('http');
const url = require('url');
const fs = require('fs');
const server = http.createServer(function(request, response) {
const path = url.parse(request.url).pathname;
switch (path) {
case '/':
response.writeHead(200, {
'Content-Type': 'text/plain'
});
response.write("This is Test Message.");
response.end();
break;
case '/images/Prismatic-Thumbs-Up-Social-Media-Word-Cloud.svg':
fs.readFile(__dirname + path, function(error, data) {
console.log(__dirname + path);
console.log("Imagen");
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'image/svg+xml'
});
response.write(data);
response.end();
}
});
break;
case '/images/DevOpsCarsalesLogo.png':
fs.readFile(__dirname + path, function(error, data) {
console.log(__dirname + path);
console.log("Imagen");
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'image/png'
});
response.write(data);
response.end();
}
});
break;
case '/images/cloud_logo.png':
fs.readFile(__dirname + path, function(error, data) {
console.log(__dirname + path);
console.log("Logo Imagen");
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'image/png'
});
response.write(data);
response.end();
}
});
break;
case '/index.html':
fs.readFile(__dirname + path, function(error, data) {
console.log(__dirname + path);
console.log("hola");
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'text/html'
});
response.write(data);
response.end();
}
});
break;
case '/about.html':
fs.readFile(__dirname + path, function(error, data) {
if (error) {
response.writeHead(404);
response.write(error);
response.end();
} else {
response.writeHead(200, {
'Content-Type': 'text/html'
});
response.write(data);
response.end();
}
});
break;
default:
response.writeHead(404);
response.write("opps this doesn't exist - 404");
response.end();
break;
}
});
server.listen(PORT)