Skip to content

Instantly share code, notes, and snippets.

@dbehnke
Last active August 29, 2015 13:56
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 dbehnke/9003473 to your computer and use it in GitHub Desktop.
Save dbehnke/9003473 to your computer and use it in GitHub Desktop.
create a simple static web server for development with node.js
/*
Simple test webserver for static content - the docs are bigger than the code!
1. install node and npm: http://nodejs.org/
2. create a directory where you want your little web server
3. cd to that directory
4. save this file you are reading to that directory as app.js
5. npm install express
6. mkdir public
7. put your static content in public
8. run the server: node app.js
9. open http://localhost:3000/local/yourwebpage.html in browser
*/
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/public'));
app.listen(process.env.PORT || 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment