Skip to content

Commit

Permalink
- init
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkarnez committed Jun 3, 2019
1 parent 14932e4 commit 7b8ba8d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[prune]
go-tests = true
unused-packages = true
36 changes: 36 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"log"
"net/http"
"flag"
"fmt"
"os"
)

var (
port string
root string
)

func main() {
flag.StringVar(&port, "port", "", "Port, default is 9999")
flag.StringVar(&root, "root", "", "Absolute path for root directory")
flag.Parse()

if len(root) < 1 {
dir, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
root = dir
}

if len(port) < 1 {
port = "80"
}

http.Handle("/", http.FileServer(http.Dir(root)))
log.Println(fmt.Sprintf("Listening on %s, serving %s", port, root))
http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
}

0 comments on commit 7b8ba8d

Please sign in to comment.