-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (26 loc) · 1.12 KB
/
Copy pathserver.js
File metadata and controls
35 lines (26 loc) · 1.12 KB
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
// COPY THE TEXT HERE AND PASTE INTO YOUR SERVER.JS FILE
"use strict";
var express = require('express');
var app = express();
var path = require('path');
var port = process.env.PORT || '3000';
//========================================================//
// connecting the client and server //
// allows for CORS (cross origin resource sharing) //
//========================================================//
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();
});
app.use(express.static(path.normalize(__dirname + '/')));
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
//========================================================//
// Calling the server //
//========================================================//
var server = app.listen(port, function() {
var host = server.address().address;
console.log('MyDeploymentApp is listening at http://%s:%s -- %s', host, port);
});