mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-27 21:51:47 +00:00
Fix game-of-life example inconsistencies; Fix ternary expression issues in void contexts and variable statements; Simplify HEAP_BASE handling
This commit is contained in:
@ -1,18 +1,32 @@
|
||||
var open = require('opn');
|
||||
var http = require('http');
|
||||
var fs = require('fs');
|
||||
var http = require("http");
|
||||
var fs = require("fs");
|
||||
var open = require("opn");
|
||||
|
||||
const PORT = 9080;
|
||||
const PORT = 9080;
|
||||
|
||||
fs.readFile('./game-of-life.html', function (err, html) {
|
||||
|
||||
if (err) throw err;
|
||||
|
||||
http.createServer(function(request, response) {
|
||||
response.writeHeader(200, {"Content-Type": "text/html"});
|
||||
response.write(html);
|
||||
response.end();
|
||||
}).listen(PORT);
|
||||
http.createServer((req, res) => {
|
||||
var url = req.url;
|
||||
console.log(req.method + " " + url);
|
||||
if (/^\/([\w\-_]+(\.\w+)+)?$/i.test(url)) {
|
||||
if (url === "/") url = "/game-of-life.html";
|
||||
fs.readFile(__dirname + url, function(err, data) {
|
||||
if (err) {
|
||||
res.writeHeader(404);
|
||||
} else {
|
||||
res.writeHeader(200, {
|
||||
"Content-Type":
|
||||
/\.wasm$/.test(url) ? "application/wasm" :
|
||||
/\.(json|map)$/.test(url) ? "application/json"
|
||||
: "text/html"
|
||||
});
|
||||
res.write(data);
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
} else {
|
||||
res.writeHeader(404);
|
||||
res.end();
|
||||
}
|
||||
}).listen(PORT, () => {
|
||||
open("http://localhost:9080/");
|
||||
});
|
||||
|
||||
open('http://localhost:9080/game-of-life.html');
|
Reference in New Issue
Block a user