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