serveit

module
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: MIT

README

serveit

A simple HTTP file server in a single executable file.

Installation

  1. Download the binary for your plaform from here.
  2. Move the binary to an installation directory of your choice.
  3. Add the installation directory to your environment path.

Usage

> cd root/of/project/you/want/to/serve
> serveit
Serving on custom port
> serveit -port=7070
Serving custom file when requested resource cannot be found
> serveit -not-found-file=404.html

For single-page applications, this flag is typically set to index.html.

Serving over HTTPS

Serveit makes it simple to serve files over HTTPS by automatically creating self-signed certificates:

> serveit -tls

This command automatically generates the following files if they don't already exist:

serveit_root_ca.key Private key for Root Certificate Aurthority.
serveit_root_ca.crt Public certificate for Root Certificate Aurthority.
serveit.key Private key for server.
serveit.crt Public certificate for server, signed with serveit_root_ca.key and serveit_root_ca.crt.

Install serveit_root_ca.crt as a Trusted Root Certificate Authority in your client device to have the browser trust the connection to serveit at https://localhost:8080.

More HTTPS options

Create certificate for IP address:

> serveit -tls -hosts 192.168.0.1

Create certificate for domain name:

> serveit -tls -hosts example.com

Create certificate for multiple domain names or IP addresses:

> serveit -tls -hosts localhost,192.168.0.1,example.com

Serve on default HTTPS port (443):

> serveit -tls -hosts example.com -port 443

Developing

Required Tools
Build
> make build
Test
> make test

Directories

Path Synopsis
Package execpath provides utilities to manipulate paths relative to the executable that started the current process.
Package execpath provides utilities to manipulate paths relative to the executable that started the current process.
Package flag is a thin wrapper around Go's flag package that parses the flag values into a Config object for the rest of the application to use.
Package flag is a thin wrapper around Go's flag package that parses the flag values into a Config object for the rest of the application to use.
Package handlers contains HTTP handler functions.
Package handlers contains HTTP handler functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL