Browse Source

Добавлен дебаг режим

master
Krio 4 years ago
parent
commit
626569090c
  1. 15
      main.go

15
main.go

@ -2,6 +2,7 @@ package main
import ( import (
"embed" "embed"
"flag"
"io/fs" "io/fs"
"log" "log"
"net/http" "net/http"
@ -22,8 +23,18 @@ func main() {
http.HandleFunc("/", app.MainPageHandler) http.HandleFunc("/", app.MainPageHandler)
http.HandleFunc("/lab", app.LabPageHandler) http.HandleFunc("/lab", app.LabPageHandler)
http.Handle("/static/", http.FileServer(http.FS(app.WebFS))) debug := flag.Bool("d", false, "Debug flag for using local FS instead of embed")
http.Handle("/labs/", http.FileServer(http.FS(app.LabsFS))) 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) err := http.ListenAndServe(":80", nil)
log.Fatal(err) log.Fatal(err)

Loading…
Cancel
Save