-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (20 loc) · 787 Bytes
/
index.js
File metadata and controls
24 lines (20 loc) · 787 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
// BASE SETUP
// ======================================
// CALL THE PACKAGES --------------------
var express = require('express'); // call express
var app = express(); // define our app using express
var port = 8080
// configure our app to handle CORS requests
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type, Authorization');
next();
});
// set static files location
// used for requests that our frontend will make
app.use(express.static(__dirname + '/public'));
// START THE SERVER
// ====================================
app.listen(port);
console.log('Magic happens on port ' + port);