Make a quick Node Server

  1. Make sure Node is installed

    Open command line and type "node -v" to see.

  2. Open your favorite editor and create a file called "server.js"

        var http = require('http'),
            fs = require('fs'),
            url = require('url'),
            phaser = fs.readFileSync('phaser.html');
    
        http.createServer(function (req, res) {
            var action = url.parse(req.url, true).pathname;
            if( action.indexOf(".png") > 0) {
                var img = fs.readFileSync("." + action);
                res.writeHead(200, {'Content-Type': "image/png"});
                res.end(img, 'binary');
            } else {
                res.writeHead(200, {'Content-Type': 'text/html'});
                res.end(phaser);
            }
        }).listen(1337);
    
        console.log('Server running at localhost:1337/');
                    
  3. Create a file called "phaser.html" and store in the same directory

        <!doctype html>
        <html>
            <head>
                <title>My Phaser Game</title>
            </head>
            <body>
                <h1>Welcome to the World of Phaser!</h1>
            </body>
        </html>
                    
  4. Download and extract "assets" to the same directory

    Click here to download "assets" folder.

  5. Open command line in that directory and run:

        node server.js
  6. Open a browser to 'localhost:1337/'

    Every time you save your html file, you'll need to re-run step 5 before refreshing