-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 823 Bytes
/
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
/*jshint node:true*/
let express = require("express");
let bodyParser = require('body-parser');
let apiv1 = require('./routes/apiv1.js');
let EJS = require('ejs');
EJS.open = "<ejs>";
EJS.close = "</ejs>";
let host = process.env.PORT ? '0.0.0.0' : 'localhost';
let port = (process.env.PORT || 3456);
let url = require('url').format({hostname: host, port: port, protocol: 'http'});
let app = express();
app.use(express.static('static'));
app.set('view engine', 'ejs');
app.use( bodyParser.json() );
app.use(bodyParser.urlencoded({
extended: false
}));
app.use('/api/v1/', apiv1.router);
let http = require('http');
let server = http.createServer(app);
server.listen(port, function () {
console.log('Weather Report listening on ' + url);
});
app.get("/", function(req, res) {
return res.render('main');
});