Last active
August 29, 2015 14:00
-
-
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..")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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