forked from mies/getting-started-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 15
/
app.js
48 lines (44 loc) · 2.28 KB
/
app.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
var express = require('express');
var app = express();
var cities = {cities:["Amsterdam","Berlin","New York","San Francisco","Tokyo", "Delhi"]}
var text1 = makeid(40);
var text2 = text1+ " "+makeid(40);
var text3 = text2+ " "+makeid(40);
var text4 = text3+ " "+makeid(40);
var logs = ["i 1", "am 1", "here 1", "hello 1", "and 1", "you 1", "know 1", "who 1", "i 2", "am 2", "here 2", "hello 2", "hello 2", "and 2", "you 2", "know 2", "who 2", "i 3", "am 3", "here 3", "hello 3", "and 3", "hello 3", "and 3", "you 3", "know 3", "who 3", "i 4", "am 4", "here 4", "hello 4", "and 4", "we 4", "hello 4", "and 4", "you 4", "know 4", "who 4", "i 5", "am 5", "here 5", "hello 5", "or 5", "not 5", "and 5", "we 5", "hello 5", "and 5", "you 5", "know 5", "who 5", "i 6", "am 6", "here 6", "hello 6", "or 6", "not 6", "and 6", "hello 6", "and 6", "you 6", "know 6", "who 6", "i 7", "am 7", "here 7", "hello 7", "and 7", "we 7", "are 7", "here1 7", "hello 7", "and 7", "you 7", "know 7", "who 7", "i 8", "am 8", "here 8", "hello 8", "and 8", "we 8", "miss 8", "are 8", "here1 8", "hello 8", "and 8", "you 8", "know 8", "who 8"]
var i = 0
app.get('/', function(req, res){
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(JSON.stringify(cities));
res.end();
});
app.get("/error", (req, res) => {
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end();
})
app.get('/health', (req, res) => res.send({"status": "OK", "time": new Date()}))
var port = process.env.PORT || 8080;
app.listen(port);
setInterval(function(str1, str2) {
var text = makeid(40);
var ran = Math.random()
if (ran > 0.75)
text = makeid(40)+ ""+makeid(40)+ ""+makeid(40)+ ""+makeid(40)
else if (ran > 0.5)
text = makeid(40)+ ""+makeid(40)+ ""+makeid(40)
else if (ran > 0.25)
text = makeid(40)+ ""+makeid(40)
//console.log(str1 + "" + str2 + "" + text+ "" +makeid(40) + "args2" + process.argv);
console.log(logs[i])
i++
if (i == logs.length) i = 0
}, 1, "Hello.", "How are you?");
function makeid(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
//just a comment
module.exports = app;