7c1e2fb228
Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
33 lines
535 B
Go
33 lines
535 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
staticFolder := os.Getenv("STATIC_FOLDER")
|
|
if staticFolder == "" {
|
|
staticFolder = "static"
|
|
}
|
|
|
|
fsHandler := http.FileServer(http.Dir(staticFolder))
|
|
apiHandler := NewApiHandler()
|
|
|
|
mux := http.NewServeMux()
|
|
mux.Handle("/", fsHandler)
|
|
mux.Handle("/api/", apiHandler)
|
|
|
|
log.Println("Listening on port", port)
|
|
err := http.ListenAndServe(":"+port, mux)
|
|
if err != nil {
|
|
log.Fatalln(err.Error())
|
|
}
|
|
}
|