-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (26 loc) · 976 Bytes
/
index.js
File metadata and controls
39 lines (26 loc) · 976 Bytes
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
var express = require('express');
var app = express();
var os = require("os");
var ip = require("ip");
// set the port of our application
// process.env.PORT lets the port be set by Heroku
var port = process.env.PORT || 5000;
// set the view engine to ejs
app.set('view engine', 'ejs');
// make express look in the public directory for assets (css/js/img)
app.use(express.static(__dirname + '/public'));
app.get('/about', function(req, res) {
// ejs render automatically looks in the views folder
res.render('index');
});
app.get(/./, function (req, res) {
var id = req.headers.host
var returnObject = {"IP Address": ip.address(), "language": req.headers['accept-language'].slice(0,6), "software" :req.headers['user-agent'].split(/[\(\)]/)[1]}
res.writeHead(200, {
'Content-Type': 'application/json'
});
res.end(JSON.stringify(returnObject));
});
app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});