handler/handler.go
Caleb Vorderbruggen 194cb62412 initial
2022-04-18 18:13:53 -04:00

29 lines
703 B
Go

/*
Project: Handler
Purpose: Provide simple HTTP file server; Its so simple to do with golang; looks like nobody bothers to provide a ready-to-download package to actually do it.
Author: Caleb Vorderbruggen <calebvorderbruggen@thirdage.dev>
*/
package main
import (
"flag"
"log"
"net/http"
)
func main() {
p := flag.String("p", "8080", "HTTP Server Port")
dir := flag.String("d", "./", "Directory to serve")
address := flag.String("a", "0.0.0.0", "IP Address to use")
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(*dir)))
log.Printf("Serving HTTP on %s port %s at %s (http://%s:%s/)\n", *address, *p, *dir, *address, *p)
log.Fatal(http.ListenAndServe(*address+":"+*p, nil))
}