-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (39 loc) · 1.35 KB
/
server.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
/*'use strict';
var express = require('express');
var routes = require('./app/routes/index.js');
var mongoose = require('mongoose');
var passport = require('passport');
var session = require('express-session');
var app = express();
require('dotenv').load();
require('./app/config/passport')(passport);
mongoose.connect(process.env.MONGO_URI);
app.use('/controllers', express.static(process.cwd() + '/app/controllers'));
app.use('/public', express.static(process.cwd() + '/public'));
app.use('/common', express.static(process.cwd() + '/app/common'));
app.use(session({
secret: 'secretClementine',
resave: false,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
routes(app, passport);
*/
var express=require("express");
var app=express();
var port = process.env.PORT || 8080;
var host={};
app.get("/",function(req,res){
//host["IP"]=req.ip;
/*res.send("it works...");*/
host.ipaddress=req.headers['x-forwarded-for'];//req.connection.remoteAddress;//req.ip.split(":")[3];
host.language=req.headers["accept-language"].split(",")[0];
host.software=req.headers['user-agent'].split(') ')[0].split(' (')[1];
res.send(host);
/*console.log('User-Agent: ' + req.headers['user-agent']);
res.send(JSON.stringify(req.get('user-agent')));*/
})
app.listen(port, function () {
console.log('Node.js listening on port ' + port + '...');
});