Giter VIP home page Giter VIP logo

antinode's Introduction

Antinode is a simple static file webserver built on node.js.

Usage

Run it from the command line.

$ node server.js [settings.json]

Requires Node.JS v0.1.100 or greater. If you want to bind to a port under 1024, you'll need to run node with special privileges.

Configuration

Configuration is through a JSON text file, by default the settings.json in the same folder as server.js.

Example settings file:

{
    "port" : 8080,
    "hosts" : {
        "subdomain1.example.com" : { 
            "root" : "/www/subdomain1/"
        },
        "subdomain2.example.com" : {
            "root" : "/www/subdomain2/"
        }
        },
    "default_host" : {
        "root" : "/www/default/"
    }
}

This server listens on port 8080 for HTTP requests. If it gets a request for Host: subdomain1.example.com the site will serve /www/subdomain1/, and similarly requests for Host: subdomain2.example.com will respond with the files from /www/subdomain2. If the Host header does not match either, or is not given, antinode will serve files from /www/default.

Explanation of properties:

  • port - the port to listen for HTTP connections on. default: 8080
  • hosts - an object with one property name per virtual host address, with the value of a 'virtual host' object to
  • default_host - the 'virtual host' object to default to if no other virtual hosts match, or the HTTP Host header is not given

'virtual host object' - has a property root giving the directory to serve web requests from

This serves up all the files in /var/www listening to HTTP requests on port 8080. E.g. an HTTP request for /styles/site.css will will look for the file /var/www/styles/site.css

Features

  • HTTP Content-Type header detection from file extension
  • HTTP Content-Length header support
  • HTTP Date header
  • HTTP Last-Modified header
  • Reads files in binary mode - so can serve images and other binary files (not just text)
  • Requests to any directory try to return directory/index.html
  • Virtual Hosts

Test Suite

To run the tests:

$ node runtests.js

Credits

Original code forked from Noah Sloan's simple logging webserver.

antinode's People

Contributors

bnoordhuis avatar hanshuebner avatar iamnoah avatar mhansen avatar psanford avatar thedjinn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.