I’ve recently found myself doing a lot of experiments in HTML that are only composed of client-side code. The trick is that to properly test them, you have to serve the pages through a host of some kind – anything that you open directly using the
file: protocol runs into security measures that prevent the page access to certain types of assets and requests.
In the past I’ve either launched Chrome with
--allow-file-access-from-files and used the
file: protocol, or served the files through a local Apache or Nginx server. Since I’m lazy, I decided these options were too much work and that instead I wanted a simple CLI to spin up small servers for any local directory.
This morning I wrote
dumbwaiter, a tiny, 11 line
npm module for doing just that by using the
1 2 3 4 5 6 7 8 9 10 11
npm install -g dumbwaiter, then run as
dumbwaiter [rootDir] [port].