From 626569090c37c0d4de669a50ee7208cf7014d9cb Mon Sep 17 00:00:00 2001 From: Krio Date: Tue, 7 Sep 2021 08:43:16 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B4=D0=B5=D0=B1=D0=B0=D0=B3=20=D1=80=D0=B5=D0=B6?= =?UTF-8?q?=D0=B8=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 53eab59..f8968fc 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "embed" + "flag" "io/fs" "log" "net/http" @@ -22,8 +23,18 @@ func main() { http.HandleFunc("/", app.MainPageHandler) http.HandleFunc("/lab", app.LabPageHandler) - http.Handle("/static/", http.FileServer(http.FS(app.WebFS))) - http.Handle("/labs/", http.FileServer(http.FS(app.LabsFS))) + debug := flag.Bool("d", false, "Debug flag for using local FS instead of embed") + flag.Parse() + + if *debug { + http.Handle("/static/", http.FileServer(http.Dir("./web"))) + http.Handle("/labs/", http.StripPrefix("/labs", http.FileServer(http.Dir("./labs")))) + log.Println("Starting in debug mode...") + } else { + http.Handle("/static/", http.FileServer(http.FS(app.WebFS))) + http.Handle("/labs/", http.FileServer(http.FS(app.LabsFS))) + log.Println("Starting in normal mode...") + } err := http.ListenAndServe(":80", nil) log.Fatal(err)