npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

httpserver

v0.3.0

Published

command line HTTP server tool for serving up local files, similar to python -mSimpleHTTPServer

Downloads

349

Readme

httpserver

command line HTTP server tool for serving up local files, similar to python -mSimpleHTTPServer

Installation

First, install Node.js. Then:

npm install -g httpserver

Usage

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:8080

See 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 localhost

or

$ HTTPSERVER_PORT=80 HTTPSERVER_HOST=127.0.0.1 httpserver

example

$ 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_HOST host to serve from, defaults to 0.0.0.0
  • HTTPSERVER_PORT port to serve from, defaults to 8080
  • HTTPSERVER_NO_INDEX disable reading of index.html/index.htm if found
  • HTTPSERVER_NO_DIR_LISTING return 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 exit

Why?

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 ?json for JSON
  • Proper HTTP - Proper Mime types (using the Mime module) and Caching headers are returned

License

MIT