Skip to content

Instantly share code, notes, and snippets.

@findzen
Forked from 8bitDesigner/README.md
Created September 25, 2013 17:55
Show Gist options
  • Save findzen/6703420 to your computer and use it in GitHub Desktop.
Save findzen/6703420 to your computer and use it in GitHub Desktop.
var express = require('express')
, app = express()
, path = __dirname + (process.argv[2] || './')
, port = process.argv[3] || 3000
app.use(express.static(path));
app.listen(port, function() { console.log('Listening on port '+port+' serving files from '+path) });

6-Line Static file server

Handy for when working on single-page apps

Usage

  1. Copy server.js to your project
  2. npm install express
  3. node ./server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment