• Stars
    star
    212
  • Rank 186,122 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tiny portable HTTP file server. single binary, no dependencies. linux, osx, windows. #golang

http-file-server

http-file-server is a dependency-free HTTP file server. Beyond directory listings and file downloads, it lets you download a whole directory as as .zip or .tar.gz (generated on-the-fly).

screenshot

Contents

Examples

Serving a path at /

$ http-file-server /tmp
2018/11/13 23:00:03 serving local path "/tmp" on "/tmp/"
2018/11/13 23:00:03 redirecting to "/tmp/" from "/"
2018/11/13 23:00:03 http-file-server listening on ":8080"

Serving $PWD at /

$ cd /tmp
$ http-file-server
2018/12/13 03:18:00 serving local path "/tmp" on "/tmp/"
2018/12/13 03:18:00 redirecting to "/tmp/" from "/"
2018/12/13 03:18:00 http-file-server listening on ":8080"

Serving multiple paths, setting the HTTP port via CLI arguments

$ http-file-server -p 1234 /1=/tmp /2=/var/tmp
2018/11/13 23:01:44 serving local path "/tmp" on "/1/"
2018/11/13 23:01:44 serving local path "/var/tmp" on "/2/"
2018/11/13 23:01:44 redirecting to "/1/" from "/"
2018/11/13 23:01:44 http-file-server listening on ":1234"

Setting the HTTP port via environment variables

$ export PORT=9999
$ http-file-server /abc/def/ghi=/tmp
2018/11/13 23:05:52 serving local path "/tmp" on "/abc/def/ghi/"
2018/11/13 23:05:52 redirecting to "/abc/def/ghi/" from "/"
2018/11/13 23:05:52 http-file-server listening on ":9999"

Uploading files using cURL

$ ./http-file-server -uploads /=/path/to/serve
2020/03/10 22:00:54 serving local path "/path/to/serve" on "/"
2020/03/10 22:00:54 http-file-server listening on ":8080"
curl -LF "[email protected]" localhost:8080/path/to/upload/to

HTTPS (SSL/TLS)

To terminate SSL at the file server, set -ssl-cert (SSL_CERTIFICATE) and -ssl-key (SSL_KEY) to the respective files' paths:

$ ./http-file-server -port 8443 -ssl-cert server.crt -ssl-key server.key
2020/03/10 22:00:54 http-file-server (HTTPS) listening on ":8443"

Get it

Using go get

go get -u github.com/sgreben/http-file-server

Pre-built binary

Or download a binary from the releases page, or from the shell:

# Linux
curl -L https://github.com/sgreben/http-file-server/releases/download/1.6.1/http-file-server_1.6.1_linux_x86_64.tar.gz | tar xz

# OS X
curl -L https://github.com/sgreben/http-file-server/releases/download/1.6.1/http-file-server_1.6.1_osx_x86_64.tar.gz | tar xz

# Windows
curl -LO https://github.com/sgreben/http-file-server/releases/download/1.6.1/http-file-server_1.6.1_windows_x86_64.zip
unzip http-file-server_1.6.1_windows_x86_64.zip

Use it

http-file-server [OPTIONS] [[ROUTE=]PATH] [[ROUTE=]PATH...]
Usage of http-file-server:
  -a string
    	(alias for -addr) (default ":8080")
  -addr string
    	address to listen on (environment variable "ADDR") (default ":8080")
  -p int
    	(alias for -port)
  -port int
    	port to listen on (overrides -addr port) (environment variable "PORT")
  -q	(alias for -quiet)
  -quiet
    	disable all log output (environment variable "QUIET")
  -r value
    	(alias for -route)
  -route value
    	a route definition ROUTE=PATH (ROUTE defaults to basename of PATH if omitted)
  -ssl-cert string
    	path to SSL server certificate (environment variable "SSL_CERTIFICATE")
  -ssl-key string
    	path to SSL private key (environment variable "SSL_KEY")
  -u	(alias for -uploads)
  -uploads
    	allow uploads (environment variable "UPLOADS")

More Repositories

1

jp

dead simple terminal plots from JSON data. single binary, no dependencies. linux, osx, windows.
Go
1,316
star
2

yeetgif

gif effects CLI. single binary, no dependencies. linux, osx, windows. #1 workplace productivity booster. #yeetgif #eggplant #golang
Go
556
star
3

tj

stdin line timestamps. single binary, no dependencies. osx & linux & windows. plays well with jq.
Go
230
star
4

ok

OCaml implementation of the K 2.0 array programming language
OCaml
80
star
5

regex-builder

Write regular expressions in pure Java
Java
61
star
6

flagvar

A collection of CLI argument types for the Go `flag` package.
Go
43
star
7

slack-emoji-upload

Slack emoji uploader, CLI. single binary, no dependencies. linux, osx, windows.
Go
32
star
8

testing-with-gomock

Supporting materials for the blog post "Testing with GoMock"
Go
26
star
9

piecewiselinear

tiny linear interpolation library for go
Go
26
star
10

jira-project-export

Export issues and metadata for a single JIRA project as JSON.
Shell
19
star
11

subst

substitutes $variables in text. single binary, no dependencies. linux, osx, windows.
Go
14
star
12

render

A flexible go-template renderer.
Go
13
star
13

ezrgif

Easy GIF effects for Slack/Discord emoji, from the command line
Shell
13
star
14

sshtunnel

library providing a convenient dialer for SSH-tunneled TCP and Unix domain socket connections. #golang
Go
13
star
15

telegram-sticker-thief-bot

Telegram bot to clone/re-combine sticker packs. Single binary, no dependencies. linux, osx, windows. #golang #cli #telegram
Go
11
star
16

image-palette-tools

extract palettes from images / cluster images by their palettes
Go
11
star
17

ocaml-rename

An .mli-aware command-line renaming tool for OCaml projects
OCaml
11
star
18

telegram-emoji-reactions-bot

Telegram bot for Slack-like emoji reactions. Single binary, no dependencies. linux, osx, windows. #golang #cli #telegram #slack
Go
10
star
19

ocaml-redis-protocol

Redis Serialization Protocol (RESP) for OCaml
OCaml
9
star
20

FsTypeVis

Simple visualisation for F# types
F#
8
star
21

with-ssh-docker-socket

access a remote Docker daemon over SSH. single binary, no dependencies. linux, osx, windows.
Go
7
star
22

digitalproductid

decodes the Windows 7/8/10 license key from the registry
Go
7
star
23

tcp-time

measures TCP connection durations to a given target, prints JSON
Go
7
star
24

versions

command-line version operations. single static binary. osx, linux, windows.
Go
5
star
25

docker-awscli

Docker image for the AWS CLI (automatically tracks AWS CLI releases)
Dockerfile
4
star
26

terrafile-ify

Generate Terrafiles and (optionally) re-write Terraform source to use vendored modules
Go
4
star
27

0sh

very simple (sub-POSIX) shell for scripting. single binary, no dependencies. osx, linux, windows. #golang
Go
4
star
28

symbolic-plc

Symbolic execution for IEC 61131 PLCs using F# and Z3
F#
4
star
29

url

command-line URL parser. single binary, no dependencies. osx & linux & windows.
Go
4
star
30

stdin-spinner

terminal spinner indicating whether data is coming in on stdin. single binary, no dependencies. linux, osx, windows.
Go
3
star
31

gopass-jsonapi-encode

reads JSON on stdin and writes gopass JSONAPI messages on stdout. single binary, no dependencies. linux, osx, windows. #golang
Go
3
star
32

http-echo

tiny HTTP server that echoes the requests it receives. single binary, no dependencies. linux, osx, windows.
Go
3
star
33

caretStack

R package for stacking caret models
R
2
star
34

docker-awscli-with-assume-role

Docker image for the AWS CLI with a wrapper that automatically assumes an IAM role (upstream AWS CLI releases are tracked automatically)
Shell
2
star
35

rc

A rule checker library for Java. Checks sets of rules for completeness, overlap, and constraint satisfaction.
Java
1
star
36

http-subst-server

tiny static file server, with dead simple templates (just $VARIABLES). single binary, no dependencies. linux, osx, windows. #golang
Go
1
star
37

docker-awsebcli

Docker image for the AWS Elastic Beanstalk CLI (automatically tracks AWS EB CLI releases)
Dockerfile
1
star
38

watchfs

docker-aware nodemon-like filesystem event watcher. single binary, no dependencies. linux, osx, windows.
Go
1
star
39

docker-awsebcli-with-assume-role

Docker image for the AWS EB CLI with a wrapper that automatically assumes an IAM role (upstream AWS EB CLI releases are tracked automatically)
Shell
1
star
40

slack-wipe

deletes all your messages and/or files in a single Slack channel. single binary, no dependencies. linux, osx, windows. #golang
Go
1
star
41

csv-dl

csv-dl reads CSV on stdin, and downloads linked files. single binary, no dependencies. linux, osx, windows. #golang
Go
1
star