開発している時に必要なのがローカルで使えるHTTPサーバです。ワンライナーで実行できるものもありますが、機能的に物足りないと感じることもあるでしょう。 そこで使ってみたいのがdevdです。プログラミングは使えませんが、高機能な開発用のHTTPサーバです。

devdの使い方

devdをカレントディレクトリをルートとして実行する場合は次のように入力します。

$ devd -ol .
15:52:02: Listening on http://devd.io:8000 (127.0.0.1:8000)
15:52:03: GET /
  < - 200 OK 1.8kB
15:52:03: GET /favicon.ico
  <- 404 Not Found 
15:52:12: GET /Kathamo-3.0.0
  <- 301 Moved Permanently 
15:52:12: GET /Kathamo-3.0.0/
  <- 200 OK 1.6kB
15:52:14: GET /Kathamo-3.0.0/demo.html
  <- 200 OK 21kB
15:52:14: GET /Kathamo-3.0.0/kathamo.min.css
  <- 200 OK 14kB

devdのヘルプです。-lはライブリロード、-oは実行した後にそのままブラウザを開いてくれるオプションになります。

$ devd --help
usage: devd [<flags>] <route>...

Flags:
      --help                 Show context-sensitive help (also try --help-long and --help-man).
  -A, --address="127.0.0.1"  Address to listen on
  -a, --all                  Listen on all addresses
  -c, --cert=PATH            Certificate bundle file - enables TLS
  -d, --down=N               Throttle downstream from the client to N kilobytes per second
  -H, --logheaders           Log headers
  -I, --ignore=REGEX         Disable logging matching requests. Regexes are matched over 'host/path'
  -l, --livereload           Enable livereload for static files
  -n, --latency=N            Add N milliseconds of round-trip latency
  -o, --open                 Open browser window on startup
  -p, --port=PORT            Port to listen on - if not specified, devd will auto-pick a sensible port
  -P, --password=USER:PASS   HTTP basic password protection
  -q, --quiet                Silence all logs
  -T, --logtime              Log timing
  -u, --up=N                 Throttle upstream from the client to N kilobytes per second
  -w, --watch=PATH           Watch path to trigger livereload
  -x, --exclude=PATTERN      Glob pattern for files to exclude from livereload
      --debug                Debugging for devd development
      --version              Show application version.

Args:
  </route><route>  Routes have the following forms:
           
             	[SUBDOMAIN]/<path>=<dir>
             	[SUBDOMAIN]/<path>=<url>
             	<dir>
             	<url>

devdは証明書が指定できるのが便利です。HTTPSを使った時の開発にも利用できます。また、監視してライブリロードすることもできるので静的サイトをさくさくと開発していくのに便利ではないでしょうか。

devdはGo製、MIT Licenseのオープンソース・ソフトウェアです。

cortesi/devd