-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
app.js
82 lines (61 loc) · 2.3 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
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
var express = require("express");
const path = require('path');
const cfenv = require('cfenv');
var app = express();
var appEnv = cfenv.getAppEnv();
var portNumber = process.env.port || 3000;
var url = process.env.url
app.set('port', (process.env.PORT || 5000))
app.use(express.static(__dirname + '/images'))
/*
app.get("/getCall", function(req,res){
console.log("GET Method caled");
console.log(__dirname);
res.send("<h2>Welcome to Node JS express app</h2>"+appEnv.url+appEnv.port+port+process.env.LOGNAME);
}).listen(9009);
console.log(__dirname+"/images/mithunlogo.jpg");
*/
app.get('/mithuntechnologies', function(request, response) {
//response.send("<h2><center>Welcome to Node JS app</h2>");
response.write("<h2><center><u>Node JS Application </u></center></h2>");
response.write("<h2><center>Welcome to Mithun Technologies. Please Contact +91-9980923226 for more information or send an email to [email protected] <center></h2>" );
response.end();
})
//app.get("/html", function(req,res){
app.get("/html", function(req,res){
res.set("Content-Type","text/html");
//res.contentType("html") ;
res.write("<h2>Welcome</h2>");
res.write("<h2>/html call</h2>");
//must end
res.end();
});
app.get("/jsonData", function(req,res){
res.type('json');
//res.type('application/json');
//res.json({'name': 'Mithun Reddy L'});
res.send({'name': 'Mithun Technologies',
'technology': 'DevOps'
});
});
app.get("/queryparam", function(req,res){
//res.send(req.query);
res.send(req.query.key + ": " + req.query.name);
});
app.get("/status-code-404", function(req, res) {
//set content-type to application/json
//res.sendStatus(404);
res.status(404).send('Sorry, we cannot find that!');
})
app.get("/status-code-500", function(req, res) {
//set content-type to application/json
//res.sendStatus(500);
res.status(500).send('Internal Server Error – custom message');
})
app.get('/redirect', function(req, res) {
//Send status 300
res.redirect('http://mithuntechnologies.com');
});
app.listen(app.get('port'), function() {
console.log("Node JS app is running at http://localhost:" + app.get('port') +"/mithuntechnologies");
})