http_this is a tiny command-line web server for the
directory you are standing in.
It is the sort of tool you reach for when you want to answer one simple question: “Can I see these files in a browser right now?” It starts a local HTTP server, serves the current directory, prints the URL, and stays out of your way.
http_this
By default, that serves the current directory on:
http://127.0.0.1:7007/
You can also serve a different directory:
http_this ~/Downloads
For more background on why this exists and why it is handy, see Dave Cross’s write-up: App::HTTPThis: The tiny web server I keep reaching for.
There are plenty of ways to start a quick web server.
http_this is useful because it is deliberately small and
boring:
index.html files when you want that
behaviorIt is useful for previewing static HTML, sharing generated files with a local browser, checking exported documentation, or quickly browsing a directory tree without setting up a larger web server.
Install from CPAN:
cpanm App::HTTPThis
or with the standard CPAN client:
cpan App::HTTPThis
Serve the current directory:
http_this
Serve another directory:
http_this path/to/files
Use a different port:
http_this --port 9001
Use prettier directory listings:
http_this --pretty
Serve index.html for directory requests when
present:
http_this --autoindex
Print the installed version:
http_this --version
Since version 1.0.0, http_this binds to
127.0.0.1 by default. That means only this computer can
connect to it unless you explicitly choose otherwise.
To bind to a specific address:
http_this --host 192.168.1.23
To deliberately listen on all network interfaces:
http_this --all
--promiscuous is also accepted as an alias for
--all.
Use --all only when you really do want other machines on
your network to be able to reach the files you are serving.
If you run http_this inside WSL and open the page from a
browser running on Windows, 127.0.0.1 may not be enough. In
that setup, WSL has its own network address.
Use:
http_this --wsl
This binds to the non-loopback IPv4 address selected by the WSL
default route and prints a URL that a Windows browser can open. It is
narrower than --all because it binds to one WSL address
rather than 0.0.0.0.
You can make that your default in .http_thisrc:
wsl=1
http_this looks for configuration in this order:
--configHTTP_THIS_CONFIG.http_thisrc in the current directory.http_thisrc in your home directoryThe file format is simple key=value data:
port=9001
pretty=1
autoindex=1
Supported keys are:
porthostnameallwslautoindexprettyCommand-line options override configuration values.
http_this can advertise itself over
Bonjour/mDNS/DNS-SD:
http_this --name "My shared files"
This requires Net::Rendezvous::Publish and an
appropriate backend for your platform. See BONJOUR.md for more detail.
--port PORT listen on a different port
--host HOST bind to a specific host or IP address
--wsl bind to the WSL address for Windows browser access
--all bind to all network interfaces
--promiscuous alias for --all
--name NAME publish the server over Bonjour/mDNS
--autoindex serve index.html for directory requests when present
--pretty use prettier directory listings
--config FILE read configuration from FILE
--version print the installed version
--help show usage information
--man show the full manual page
App::HTTPThis is intentionally thin. The command parses
options and config, then starts a Plack::Runner serving a
Plack::App::DirectoryIndex app. Plack does the heavy
lifting; this distribution provides the convenient CLI and the small
bits of behavior that make it pleasant to use.
This software is free software, licensed under the Artistic License 2.0.