The simple file server command.
This code is literally to simplify my life by making it so that instead of typing a few words in the command line to open a file server, I only have to write one word (not including options like port and directory).
Why did I do this? Because I'm a lazy guy who would rather make my life easier by writing less in the terminal.
go get github.com/probably-not/servedir
cd $(go env GOPATH)/src/github.com/probably-not/servedir
go install
To serve the current directory on port 8080
:
servedir
To serve the current directory on a different port:
servedir --port 8000
Or, using the shorthand:
servedir -p 8000
To serve a different directory on port 8080
:
servedir --dir /some/random/dir
Or, using the shorthand:
servedir -d /some/random/dir
Well, some time passed, and then I realized, what if I want to see how my files are compressed? So... I added some brotli compression!
To serve files with compression, simply run the normal command. Compression and best compression is on by default.
To turn off compression:
servedir --compression false
Or, using the shorthand:
servedir -c false
To change the level of compression (can be between 0 and 11):
servedir --level 1
Or, using the shorthand:
servedir -l 1