Socket
Socket
Sign inDemoInstall

statik

Package Overview
Dependencies
27
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    statik

Simple static file server – serve any directory over HTTP


Version published
Maintainers
1
Install size
4.18 MB
Created

Readme

Source

Statik

A simple and easy-to-use Node.js module to server static files over HTTP. It's super simple to use it.

Command line usage

$ npm install -g statik
$ cd ~/Sites
$ statik

Then head to http://localhost:3000/ to see the contents of ./public served over HTTP.

Customise the default directory and port

// Start server at http://localhost:3000 serving ./public
$ static --port 3000

// Start server at http://localhost:3000 serving ~/Sites/project
$ statik --port 3000 ~/Sites/project

Other command line options

  • maxAge: browser cache maxAge in milliseconds. Defaults to 0
  • hidden: allow transfer of hidden files. Defaults to false
  • redirect: redirect to trailing "/" when pathname is directory. Defaults to true
  • compress: enable gzip compression. Defaults to true
  • verbose: enable logging to stdout. Defaults to false

Use it programmatically

$ npm install statik --save

Usage

// app.js
var statik = require('statik');
statik(3000);

Your server will be running on http://localhost:3000/ serving ./public directory.

Customisations

You can specify the directory you wish to serve as an argument.

// app.js
var statik = require('statik');
statik({
	port: 3000,
	root: '/Users/hongymagic/Sites'
});

Your server will be running on http://localhost:3000/ server /Users/hongymagic/sites directory.

You can also use command line options when invoking statik function.

Running it on heroku

$ echo 'web: node app.js' > Procfile
$ heroku create --stack cedar statik-app
$ git push heroku master
$ heroku open

BAM!

FAQ

Why?

Because I hate file:// protocol for the reasons I wish not to disclose. One of the recent ones I've come across is Typekit. And trust me there are other problems that pop-up if you're primarily working for the http:// protocol.

What about the HTTP Headers?

There are some default HTTP Headers that I am going to introduce for the reaons why I have create this package in the first place:

  1. Content-Type: statik uses another internal Node.js package mime to check against content types
  2. Cache-Control: 'no-cache'. The primary purpose of statik was so I could easily run a folder as web server over HTTP while I'm working on a new site. Might as well kill off the cache while I'm writing and debugging CSS and JavaScript. There will be an option to disable to default behaviour though.

How does statik treat root /?

For now, it will translate that into index.html

TODO

  1. Clean up code around 404 and 500 errors
  2. Options to add/remove default HTTP headers
  3. Default set of files instead of index.html

Keywords

FAQs

Last updated on 19 Nov 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc