-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (23 loc) · 737 Bytes
/
index.js
File metadata and controls
28 lines (23 loc) · 737 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
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var cfg = {
port: process.env.PORT || 8080,
hostname: process.env.IP || '0.0.0.0'
};
app.set('view engine', 'ejs');
// app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(express.static(__dirname + '/public'));
// CORS headers
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var server = app.listen(cfg.port, cfg.hostname, function () {
console.log('listening on ' + cfg.hostname + ':' + cfg.port);
});
app.get('/', function (req, res) {
res.render('index');
});