Skip to content

brantxiong/file-server

 
 

Repository files navigation

File Static Server

A http file server written by golang and reactjs.

Binary can be download from gorelease

Usage

file-server -port 8000 -root /your/workdir

file-server
	-port=8000: Which port to listen
	-private=false: Only listen on lookback interface, otherwise listen on all interface
	-root=".": the HTTP File Server's root directory
	-auth="": Basic Authentication (ex: username:password)

screenshot screenshot

Features

  1. Support QRCode code generate
  2. All assets package to Standalone binary
  3. Different file type different icon
  4. Support show or hide hidden files
  5. Upload support
  6. README.md preview
  7. HTTP Basic Auth
  8. Gzip support
  9. When only one dir under dir, path will combine two together

Build

Suggest install node through nvm

npm install -g webpack
npm install
make prod

Develop

Your need to know what is react, and golang. In develop mode, Support react hot reload

npm install
make dev

Open another terminal

go build && ./file-server

API

Upload

POST /upload-dir

Field name Description Example
file Upload file file=@upload.txt
path Upload path(optional) path=/tmp/
name Save name (optional, need version set) name=foo
version Upload version version=1.2.0

Use CURL

# Normal upload
curl -F file=@upload.txt ${SERVER}

# Versioned upload
curl -F file=@foo-windows.txt -F file=@foo-mac.txt -F name=foo -F version=1.0.1 ${SERVER}

# will create dir structure
foo/
  |- foo-latest(symlink) -> foo-1.0.1
  `- foo-1.0.1/
      |- foo-windows.txt
      `- foo-mac.txt

Thanks

  1. https://github.com/shenfeng/http-watcher
  2. http://segmentfault.com/a/1190000002551952
  3. update package.json dependencies
  4. react hot reload QA
  5. https://github.com/evilstreak/markdown-js

About

File Static Server written by golang + reactjs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 67.3%
  • Go 28.1%
  • Makefile 2.6%
  • CSS 2.0%