Skip to content

Instantly share code, notes, and snippets.

@mohamed-ahmed
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamed-ahmed/c392a799c384a543d55a to your computer and use it in GitHub Desktop.
Save mohamed-ahmed/c392a799c384a543d55a to your computer and use it in GitHub Desktop.
Small block of code to serve static files using node (useful for debugging when "XMLHttpRequest cannot load file..")
var express = require('express');
var app = express();
var path = require('path');
app.get('/', function(req, res) {
res.sendfile('index.html');
});
app.use(express.static(path.join(__dirname, '/')));
app.listen(process.env.PORT || 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment