NAME
http_this - export the current directory over HTTP
SYNOPSIS
## Export the current directory with HTTP
$ http_this
## Export the dir_name directory with HTTP
$ http_this dir_name
## Bind the server to a specific port
$ http_this --port 9001
## Bind the server to one specific non-default interface
$ http_this --host 192.168.1.23
## Bind to the WSL address for access from a Windows browser
$ http_this --wsl
## WARNING: Make the server reachable on all network interfaces
$ http_this --all
## Announces the HTTP server via Bonjour with the specified name
$ http_this --name "My cool webserver"
## Start the server using index.html for directory requests
$ http_this --autoindex
## Start the server using prettier CSS for index pages
$ http_this --pretty
## Load config from a file
$ http_this --config /path/to/configrc
## Show documentation about our options
$ http_this --help
## Show the entire man page
$ http_this --man
DESCRIPTION
The http_this command exports the current directory via HTTP. You can also export any directory by providing the path as a parameter.
A simple web server is started and is kept running until you kill it with Ctrl-C.
All the files and directories will be availble to a browser under the URL the script outputs.
WARNING
As of version 1.0.0, http_this no longer listens on all network interfaces by default. It now binds to 127.0.0.1, so only this computer can access it unless you explicitly opt in to broader access.
If you need the pre-1.0.0 behaviour, use --all (or its alias --promiscuous), set all=1 in the config file, or choose a specific address with --host.
ARGUMENTS
The script accepts a single optional argument: the path of the directory to export.
OPTIONS
The following options are available:
- --port PORT
-
Start the HTTP server on a specific
PORT. - --host HOST
-
Bind the server to a specific
HOSTor IP address, such as192.168.1.23or::1. By default the server binds to127.0.0.1(localhost), which is a breaking change in version1.0.0. Use--allor--promiscuousto restore the previous behaviour of listening on all network interfaces. - --wsl
-
Bind the server to the non-loopback IPv4 address selected by the WSL default network route. This is useful when running
http_thisinside WSL and opening the URL from a browser running on Windows. The command output will show the selected WSL IP address to use in the Windows browser.This is narrower than
--all, because it binds to one WSL address rather than0.0.0.0. - --all / --promiscuous
-
WARNING: this makes the server reachable on all network interfaces (equivalent to
--host 0.0.0.0). Other machines on your network may be able to access it. Use this only when you explicitly want the pre-1.0.0 behaviour or need to share the server beyond the local machine. - --name NAME
-
Announces the server over Bonjour.
This feature requires the Net::Rendezvous::Publish module and the appropriate backend for your operating system, both available from MetaCPAN. If one of them cannot be found, a warning message will be displayed.
- --autoindex
-
By default, if the server gets a request that ends in / then it displays a listing of that directory. With the
--autoindexflag, it will serve theindex.htmlfile from that directory (if it exists). - --pretty
-
Creates default index listings using a prettier cascading stylesheet.
- --config FILE
-
Read configuration options from
FILE. See "CONFIGURATION FILE" below. - --help
-
Print information about the script usage and its options.
- --man
-
Print the entire man page for the command.
CONFIGURATION FILE
The script can read configuration options from a file. By default, it looks for a file named .http_thisrc in the current directory or your home directory. You can specify a different file with the --config option or by setting the HTTP_THIS_CONFIG environment variable.
The config file consists of lines in the format key=value. The valid keys are:
- port:
-
The port to use for the HTTP server.
- name:
-
The name to use when announcing the server over Bonjour.
- host:
-
The host or IP address to bind to. If omitted,
127.0.0.1is used. Set this to a specific address if you do not want the localhost default. - all:
-
WARNING: if set to a true value, the server will bind to all network interfaces (equivalent to
host=0.0.0.0), restoring the pre-1.0.0 behaviour. - wsl:
-
If set to a true value, the server will bind to the non-loopback IPv4 address selected by the WSL default network route. This is useful when running
http_thisinside WSL and opening the URL from a browser running on Windows. - autoindex:
-
If set to a true value, the server will serve the
index.htmlfile from a directory when it gets a request that ends in / (instead of displaying a listing of that directory). - pretty:
-
If set to a true value, the server will use a prettier cascading stylesheet for directory listings.