Error node.js Failed to load resource

I have been working with node.js and, and following a tutorial, but I keep getting an error from an application I am building. This is my server.js file:

var static = require('node-static');
var http = require('http');
var file = new(static.Server)();
var app = http.createServer(function(req, res) {
    file.serve(req, res);
var io = require('').listen(app);
io.sockets.on('connection', function(socket) {
    function log() {
        var array = [">>> Message from server: "];
        for (var i = 0; i < arguments.length; i++) {
        socket.emit('log', array);
    socket.on('message', function(message) {
        log('Got message:', message);
        socket.broadcast.emit('message', message);
    socket.on('create or join', function(room) {
        var numClients = io.sockets.clients(room).length;
        log('Room ' + room + ' has ' + numClients + ' client(s)');
        log('Request to create or join room ' + room);
        if (numClients === 0) {
            socket.emit('created', room);
        } else if (numClients === 1) {
  'join', room);
            socket.emit('joined', room);
        } else { // max two clients
            socket.emit('full', room);
        socket.emit('emit(): client ' + + ' joined room ' + room);
        socket.broadcast.emit('broadcast(): client ' + + 'joined room' + room);

However when I browse to localhost:1234 I get the error Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:1234


Put a index.html in you app root folder and it will be provided over 'node-static' as entrance file.

A more clean way is to configure a folder for all your frontend files.

var file = new static.Server('./public');

The full node-static docs can be found here:

Need Your Help

CakePHP 3: How to create custom model callbacks?

cakephp events callback cakephp-3.0 cakephp-3.1

Need good start point to create custom model callbacks. For specific part of application i can't use default cakephp lifecycle callbacks (beforeSave, afterSave,..) because table is large. In contro...

WildCard for Object<String> in Java6

java swing generics wildcard jcombobox

Please how to correct casting and remove warning