server.js 1.62 KB
Newer Older
Patrick's avatar
Patrick committed
1
const http = require('http');
Patrick's avatar
Patrick committed
2
const http = require('https');
Patrick's avatar
Patrick committed
3
4
5
6
const fs = require('fs');
const express = require('express')
const app = express();
const bodyParser = require('body-parser')
Patrick's avatar
test    
Patrick committed
7
8
// app.use(bodyParser.urlencoded({ extended: false })) 
// app.use(bodyParser.json())
Patrick's avatar
Patrick committed
9
10
const request = require('ajax-request');

Patrick's avatar
Patrick committed
11
12
13
// app.use(express.static('vcm'));
// app.listen(process.env.PORT || 8083);

Patrick's avatar
test    
Patrick committed
14
// const app = express();
Patrick's avatar
Patrick committed
15
16
17
18
19
20
21
22
23
24
25
26

// Certificate
const privateKey = fs.readFileSync('/etc/letsencrypt/live/umfrage.smartvillages.online/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/umfrage.smartvillages.online/cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/umfrage.smartvillages.online/chain.pem', 'utf8');

const credentials = {
	key: privateKey,
	cert: certificate,
	ca: ca
};

Patrick's avatar
Patrick committed
27
28
29
app.use((req, res) => {
	res.send('Hello there !');
});
Patrick's avatar
Patrick committed
30

Patrick's avatar
Patrick committed
31
32
33
34
// Starting both http & https servers
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);

Patrick's avatar
Patrick committed
35
36
37
httpServer.listen(8085, () => {
    console.log('HTTP Server running on port 80');
});
Patrick's avatar
Patrick committed
38

Patrick's avatar
Patrick committed
39
40
41
httpsServer.listen(8083, () => {
	console.log('HTTPS Server running on port 8083');
});
Patrick's avatar
Patrick committed
42

Patrick's avatar
Patrick committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// app.post('/addpoint', function(req,res){

//     try {

//         const data = req.body;
//          console.log("data ==============")
//          console.log(data.id);
//         args.gmlid = data.id
//          console.log(data[0]);
//          console.log(data[1]);
//          console.log("args ==============")
//          console.log(args);

//     }   
//     catch (err) {
//         console.log('.../getSimS failed!\n' + err);
//     }
//   });