Skip to content

Instantly share code, notes, and snippets.

@missinglink
Last active December 30, 2015 01:39
Show Gist options
  • Select an option

  • Save missinglink/7757339 to your computer and use it in GitHub Desktop.

Select an option

Save missinglink/7757339 to your computer and use it in GitHub Desktop.
Absolute minimal node.js static file server using connect.
/**
* Absolute minimal node.js static
* file server using connect.
*
* Directory structure.
* .
* ├── app.js ( this file )
* └── public/ ( static assets )
*
* Install & run server.
*
* > npm install connect
* > node app.js
*
* View files
*
* http://localhost:3000/myfile.ext
*
**/
var connect = require('connect');
connect.createServer( connect.static( 'public' ) ).listen( 3000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment