If you want to use Python's SimpleHTTPServer
feature but don't want to install Python, then this program might be what you need.
It will serve any locally available folder via HTTP using Go's builtin FileServer.
The project only uses Go's standard library, there are no additional dependencies.
As a prerequisite, you need to have Go installed.
You can execute the program without producing a permanent binary by running:
go run serve.go
By default, you will now have your current directory served at https://localhost/. You can give a path as a parameter to the program to serve any other directory.
Press Ctrl+C to end execution or set timeout with -t
-parameter.
Additional command line parameters for the server.
Parameter | What it does |
---|---|
-h | Display help. Basically the same thing you are reading right now. |
-p | Sets a custom port for Serve to use. Defaults to 80 (HTTP). |
-t | Timeout for execution. If you want to leave server on only for a specific period of time, this setting will end the execution after the given duration. A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "120s", "1.5h" or "2h45m". |
-l | Log requests. Will log the requester IP address and what was requested. As of now, the logging is to stdout only. |
-o | This method can be used to output HTTP URL where your files are being served. Determining this is always bit of a guess work if you want to share the files somewhere outside your own computer. Valid options are as follows: hostname - Use OS Hostname setting to determine the URL. dns - Use Google's DNS server (8.8.8.8) to determine your IP address. public - Use ipify.org to determine your IP address. All, some or none of these might work for your use case. |
-v | Verbose output. Will log additional information about what is happening in the program. |
As a prerequisite, you need to have Go installed.
If you wish to compile stand alone version of the program, simply run go build
to compile executable of your current platform.
See Go's own documentation for additional information about compilation in general and cross compilation to different platforms (Windows/Linux/macOS/etc.)