forked from julien-moreau/learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (29 loc) · 928 Bytes
/
Copy pathserver.js
File metadata and controls
35 lines (29 loc) · 928 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
29
30
31
32
33
34
35
var staticServer = null;
var createServer = function() {
// Run server
var http = require("http");
var file = new(staticServer.Server)();
http.createServer(function (req, res) {
file.serve(req, res);
}).listen(8000);
console.log("You can now access http://localhost:8000 to run your game");
var spawn = require("child_process").spawn;
spawn("open", ["http://localhost:8000/PureWebGL/index.html"]);
}
try {
staticServer = require("node-static");
createServer();
} catch (ex) {
var exec = require("child_process").exec;
var child = exec("npm install node-static", function (error, stdout, stderr) {
console.log("stdout: " + stdout);
if (error !== null) {
console.log("exec error: " + error);
}
else {
// Run server
staticServer = require("node-static");
createServer();
}
});
}