|
|
|
|
@ -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) |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|