homeservice/main.go

41 lines
731 B
Go
Raw Normal View History

2023-01-30 12:29:26 +00:00
package main
import (
2023-02-06 10:33:18 +00:00
"flag"
2023-01-30 12:29:26 +00:00
"log"
"net/http"
2023-03-01 07:12:49 +00:00
bicycle "git.blackfinn.de/apiservice/bicycle"
2023-03-01 07:11:55 +00:00
sauna "git.blackfinn.de/apiservice/sauna"
2023-01-30 12:29:26 +00:00
)
var (
2023-01-30 14:54:49 +00:00
logger log.Logger = *log.Default()
2023-01-30 12:29:26 +00:00
)
2023-01-30 14:54:49 +00:00
func init() {
logger.SetPrefix("Homeservice: ")
}
2023-01-30 12:29:26 +00:00
func main() {
2023-01-30 14:54:49 +00:00
logger.Println("starting")
2023-02-06 10:33:18 +00:00
var webui_path string
flag.StringVar(&webui_path, "d", "./build/webui", "Specify path to serve the web ui. Default is ./static")
2023-02-06 10:33:18 +00:00
flag.Parse()
2023-03-01 07:11:55 +00:00
// Start apis
2023-03-01 07:12:49 +00:00
bicycle.Start()
2023-03-01 07:11:55 +00:00
sauna.Start()
2023-01-30 12:29:26 +00:00
// Serve files from static folder
2023-02-06 10:33:18 +00:00
http.Handle("/", http.FileServer(http.Dir(webui_path)))
2023-01-30 12:29:26 +00:00
port := ":5000"
2023-01-30 14:54:49 +00:00
logger.Println("Server is running on port" + port)
2023-01-30 12:29:26 +00:00
// Start server on port specified above
2023-01-30 14:54:49 +00:00
logger.Fatal(http.ListenAndServe(port, nil))
2023-01-30 12:29:26 +00:00
}