Commits

Jesus Galan Lopez committed e9104df

instead of the -web flag, use the LEMMY_WEB env var

Comments (0)

Files changed (1)

 var (
 	addr = flag.String("http", ":8080", "http listen address")
 	root = flag.String("root", os.Getenv("HOME")+"/music/", "music root")
-	web = flag.String("web", "", "web root")
+	web string
 )
 
 func main() {
 	flag.Parse()
+	web = os.Getenv("LEMMY_WEB")
 	log.Print("root = ", *root)
-	log.Print("web = ", *web)
+	log.Print("web = ", web)
 	http.HandleFunc("/", Web)
 	http.HandleFunc(filePrefix, File)
 	http.ListenAndServe(*addr, nil)
 }
 
 func Web(w http.ResponseWriter, r *http.Request) {
-	if *web == "" {
+	if web == "" {
 		if r.URL.Path != "/" {
 			http.Error(w, "Not Found", http.StatusNotFound)
 			return
 		w.Write([]byte(index));
 		return;
 	}
-	fn := filepath.Join(*web, r.URL.Path)
+	fn := filepath.Join(web, r.URL.Path)
 	_, err := os.Stat(fn)
 	log.Print("Web file called: ", fn)