just-http

1.0.1 • Public • Published

just-http

Simple, semi-static, http server. Mostly the result of my playing around with the http and fs modules, but it may serve someone.

Installation

Install from npm:

npm install just-http

Usage

Create a new server:

var server = require("just-http").createServer();

Map path to files using regular expressions:

server.map("^/$", "./www-test/index.html");
server.map("^/(.+)$", "./www-test/$1");

Map a path to a function, to serve dynamic content:

server.map("^/dynamic$", function (request, response) {
    try {
        // TODO : do something smart
    } catch (e) {
        // never let exceptions bubble up
        server.sendError(response, e);
    }
});

Start listeneing

server.listen(8080);

Contribute

github repository:

https://github.com/freongrr/node-just-http

Readme

Keywords

none

Package Sidebar

Install

npm i just-http

Weekly Downloads

0

Version

1.0.1

License

none

Last publish

Collaborators

  • freongrr