Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Synopsis
--------

```js
var static = require('node-static');
var nodeStatic = require('node-static');

//
// Create a node-static server instance to serve the './public' folder
//
var file = new static.Server('./public');
var file = new nodeStatic.Server('./public');

require('http').createServer(function (request, response) {
request.addListener('end', function () {
Expand All @@ -36,20 +36,20 @@ API
Creating a file server instance is as simple as:

```js
new static.Server();
new nodeStatic.Server();
```

This will serve files in the current directory. If you want to serve files in a specific
directory, pass it as the first argument:

```js
new static.Server('./public');
new nodeStatic.Server('./public');
```

You can also specify how long the client is supposed to cache the files node-static serves:

```js
new static.Server('./public', { cache: 3600 });
new nodeStatic.Server('./public', { cache: 3600 });
```

This will set the `Cache-Control` header, telling clients to cache the file for an hour.
Expand All @@ -61,9 +61,9 @@ To serve files under a directory, simply call the `serve` method on a `Server` i
the HTTP request and response object:

```js
var static = require('node-static');
var nodeStatic = require('node-static');

var fileServer = new static.Server('./public');
var fileServer = new nodeStatic.Server('./public');

require('http').createServer(function (request, response) {
request.addListener('end', function () {
Expand Down Expand Up @@ -103,9 +103,9 @@ An optional callback can be passed as last argument, it will be called every tim
has been served successfully, or if there was an error serving the file:

```js
var static = require('node-static');
var nodeStatic = require('node-static');

var fileServer = new static.Server('./public');
var fileServer = new nodeStatic.Server('./public');

require('http').createServer(function (request, response) {
request.addListener('end', function () {
Expand Down
4 changes: 2 additions & 2 deletions examples/file-server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var static = require('../lib/node-static');
var nodeStatic = require('node-static');

//
// Create a node-static server to serve the current directory
//
var file = new static.Server('.', { cache: 7200, headers: {'X-Hello':'World!'} });
var file = new nodeStatic.Server('.', { cache: 7200, headers: {'X-Hello':'World!'} });

require('http').createServer(function (request, response) {
file.serve(request, response, function (err, res) {
Expand Down