httpserver v0.3.0
httpserver
command line HTTP server tool for serving up local files, similar to python -mSimpleHTTPServer
Installation
First, install Node.js. Then:
npm install -g httpserverUsage
run httpserver on the command line to fire up a server on 0.0.0.0 port 8080.
$ httpserver
{
"lo0": "127.0.0.1",
"en1": "10.0.1.204"
}
server started: http://0.0.0.0:8080See the page at http://localhost:8080.
htppserver will serve out of your current working directory.
You can pass in arguments to change the port and host, as well as environmental variables
$ httpserver 80 localhostor
$ HTTPSERVER_PORT=80 HTTPSERVER_HOST=127.0.0.1 httpserverexample
$ httpserver
{
"lo0": "127.0.0.1",
"en1": "10.0.1.204"
}
server started: http://0.0.0.0:8080
127.0.0.1 - - [30/Oct/2013:18:24:38 -0400] "GET / HTTP/1.1" 200 - "-" "curl/7.30.0"
127.0.0.1 - - [30/Oct/2013:18:24:41 -0400] "GET /test/ HTTP/1.1" 404 - "-" "curl/7.30.0"Environmental Variables
HTTPSERVER_HOSThost to serve from, defaults to0.0.0.0HTTPSERVER_PORTport to serve from, defaults to8080HTTPSERVER_NO_INDEXdisable reading of index.html/index.htm if foundHTTPSERVER_NO_DIR_LISTINGreturn 403 for directory listings
Advanced Usage
usage: httpserver [options] [port] [host]
command line HTTP server tool for serving up local files, similar to python -mSimpleHTTPServer
options
-d, --disable-index disable reading of index.html/index.htm if found, env HTTPSERVER_NO_INDEX
-h, --help print this message and exit
-H, --host <host> the host address on which to listen, env HTTPSERVER_HOST defaults to '0.0.0.0'
-n, --no-indexes return 403 for directory requests instead of a directory listing, env HTTPSERVER_NO_DIR_LISTING
-p, --port <port> the port on which to listen, env HTTPSERVER_PORT, defaults to 8080
-u, --updates check for available updates on npm
-v, --version print the version number and exitWhy?
There are a lot of packages in npm that do the same thing. I wanted something that
closely mimicked Python's python -m SimpleHTTPServer with the following conditions.
- Easy - You shouldn't have to provide arguments to get something easy up and running. The IP addresses on the machine are also printed for you
- Configurable - Command line options and environmental variables can modify behavior at runtime
- Safe - All other packages I found online were susceptible to directory traversal. This isn't
- Simple - All code is in one file
- Parsable - GET requests to directories are returned as directory listings, add
?jsonfor JSON - Proper HTTP - Proper Mime types (using the Mime module) and Caching headers are returned
License
MIT
9 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago