27 lines
423 B
Go
27 lines
423 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
args := os.Args[1:]
|
||
|
port := "8080"
|
||
|
if len(args) == 0 {
|
||
|
log.Println("Usage: quickhttp <content-dir> [port]")
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
content_dir := args[0]
|
||
|
|
||
|
if len(args) == 2 {
|
||
|
port = args[1]
|
||
|
}
|
||
|
|
||
|
// Public Views
|
||
|
fs := http.FileServer(http.Dir(content_dir))
|
||
|
http.Handle("/", fs)
|
||
|
log.Println("Listening...")
|
||
|
log.Fatal(http.ListenAndServe(":"+port, nil))
|
||
|
}
|