summaryrefslogtreecommitdiff
path: root/main.go
blob: 37f0cb8a3605fde59735450cfcddc2bb33b0f110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package main

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

func main() {
	fl := flag.NewFlagSet("Simple File Server", flag.ExitOnError)
	listen := fl.String("l", "0.0.0.0:8001", "Listening address")
	directory := fl.String("d", ".", "Directory to serve.")

	fl.Parse(os.Args[1:])

	if fl.Parsed() {
		http.Handle("/", http.FileServer(http.Dir(*directory)))
		log.Fatal(http.ListenAndServe(*listen, nil))
	}
}