Created
January 12, 2014 15:52
-
-
Save kamilogorek/8386317 to your computer and use it in GitHub Desktop.
Static node.js server with livereload
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
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script> |
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
{ | |
"name": "express-livereload-server", | |
"version": "0.0.1", | |
"description": "Simple express server with LiveReload", | |
"main": "server.js", | |
"author": "Kamil Ogórek", | |
"license": "MIT", | |
"dependencies": { | |
"express": "~3.4.4", | |
"express-livereload": "0.0.24" | |
} | |
} |
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
'use strict'; | |
var express = require('express'); | |
var livereload = require('express-livereload'); | |
var app = express(); | |
livereload(app, { | |
watchDir: process.cwd() | |
}); | |
app.get('/', function(req, res) { | |
res.redirect('/index.html'); | |
}); | |
app.configure(function () { | |
app.use(express.methodOverride()); | |
app.use(express.urlencoded()); | |
app.use(express.json()); | |
app.use(express.static(process.cwd())); | |
app.use(express.logger('dev')); | |
app.use(express.errorHandler({ | |
dumpExceptions: true, | |
showStack: true | |
})); | |
app.use(app.router); | |
}); | |
var port = process.argv[2] || 8888; | |
app.listen(port, function() { | |
console.log('Express server listening on port ' + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment