static files with express.js

express.static() expects the first parameter to be a path of a directory, not a filename. I would suggest creating another subdirectory to contain your index.html and use that.

By default this module will send “index.html” files in response to a request on a directory. To disable this set false or to supply a new index pass a string or an array in preferred order.

If you have this setup


Then this should get what you wanted

var express = require('express');
//var server = express.createServer();
// express.createServer()  is deprecated. 
var server = express(); // better instead
  server.use('/media', express.static(__dirname + '/media'));
  server.use(express.static(__dirname + '/public'));


The trick is leaving this line as last fallback

server.use(express.static(__dirname + '/public'));