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_thisBy default, that serves the current directory on:
http://127.0.0.1:7007/
You can also serve a different directory:
http_this ~/DownloadsFor 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:
- it serves static files from a directory
- it gives you directory listings
- it can serve
index.htmlfiles when you want that behavior - it is built on PSGI/Plack
- it has safe localhost-only defaults
- it has escape hatches for WSL and LAN sharing
It 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::HTTPThisor with the standard CPAN client:
cpan App::HTTPThisServe the current directory:
http_thisServe another directory:
http_this path/to/filesUse a different port:
http_this --port 9001Use prettier directory listings:
http_this --prettyServe index.html for directory requests when present:
http_this --autoindexPrint the installed version:
http_this --versionSince 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.23To 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 --wslThis 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=1http_this looks for configuration in this order:
- a file passed with
--config - the file named by
HTTP_THIS_CONFIG .http_thisrcin the current directory.http_thisrcin your home directory
The file format is simple key=value data:
port=9001
pretty=1
autoindex=1Supported keys are:
porthostnameallwslautoindexpretty
Command-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.