code-signing-final/All/server.go

30 lines
645 B
Go
Raw Normal View History

2019-11-12 01:10:00 +00:00
//go:generate goversioninfo
/*Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
import (
"flag"
2019-11-12 22:55:19 +00:00
"log"
2019-11-12 01:10:00 +00:00
"net/http"
)
func main() {
port := flag.String("p", "8100", "port to serve on")
directory := flag.String("d", ".", "the directory of static file to host")
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(*directory)))
2019-11-12 22:55:19 +00:00
log.Printf("Serving %s on HTTP port: %s\n", *directory, *port)
log.Fatal(http.ListenAndServe(":"+*port, nil))
2019-11-12 01:10:00 +00:00
}