You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
944 B
42 lines
944 B
package main |
|
|
|
import ( |
|
"embed" |
|
"flag" |
|
"io/fs" |
|
"log" |
|
"net/http" |
|
|
|
"git.atik.me/basicweb/app" |
|
) |
|
|
|
//go:embed web |
|
var webFS embed.FS |
|
|
|
//go:embed labs |
|
var labsFS embed.FS |
|
|
|
func main() { |
|
webFS, _ := fs.Sub(webFS, "web") |
|
app := app.New(labsFS, webFS) |
|
|
|
http.HandleFunc("/", app.MainPageHandler) |
|
http.HandleFunc("/lab", app.LabPageHandler) |
|
http.HandleFunc("/coursework", app.CourseworkPageHandler) |
|
|
|
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) |
|
}
|
|
|