-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
64 lines (46 loc) · 1.77 KB
/
server.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// var express = require('express');
// var app = express();
// // var morgan = require('morgan');
// // var bodyParser = require('body-parser');
// var cors = require('cors');
// // app.use(morgan('dev'));
// app.use(bodyParser.urlencoded({'extended':'true'}));
// app.use(bodyParser.json());
// app.use(cors());
// app.use(function(req, res, next) {
// res.header("Access-Control-Allow-Origin", "*");
// res.header('Access-Control-Allow-Methods', 'DELETE, PUT');
// res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
// next();
// });
// app.use(express.static('www'));
// app.set('port', process.env.PORT || 5000);
// app.listen(app.get('port'), function () {
// console.log('Express server listening on port ' + app.get('port'));
// });
//Install express server
// const express = require('express');
// const path = require('path');
// const app = express();
// // Serve only the static files form the dist directory
// app.use(express.static(__dirname + '/dist'));
// app.get('/*', function(req,res) {
// res.sendFile(path.join(__dirname+'/dist/index.html'));
// });
// // Start the app by listening on the default Heroku port
// app.listen(process.env.PORT || 8080);
var express = require('express'),
app = express();
app.use(express.static('www'));
// CORS (Cross-Origin Resource Sharing) headers to support Cross-site HTTP requests
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
// API Routes
// app.get('/blah', routeHandler);
app.set('port', process.env.PORT || 5000);
app.listen(app.get('port'), function () {
console.log('Express server listening on port ' + app.get('port'));
});