Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

filesvr sample

  • Loading branch information...
commit 27b6beeafd9c1d55c7594bb477866eea14196e3f 1 parent 51d6137
@kicool authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 net/filesvr.go
View
22 net/filesvr.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "flag"
+ "log"
+ "net/http"
+)
+
+var (
+ webroot = flag.String("root", "./", "web root directory")
+ addr = flag.String("addr", ":1981", "ipv4:port to listen")
+)
+
+func main() {
+ flag.Parse()
+
+ http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(*webroot))))
+ err := http.ListenAndServe(*addr, nil)
+ if err != nil {
+ log.Panicln("ListenAndServe:", err)
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.