Files
printctrl/src/main.go
Thomas Klaehn 35db2c1f58 Add camera control
Signed-off-by: Thomas Klaehn <thomas.klaehn@perinet.io>
2025-09-11 08:47:20 +02:00

43 lines
958 B
Go

package main
import (
"flag"
"log"
"net/http"
apiservice_camera "powerswitch/internal/apiservice/camera"
apiservice_data "powerswitch/internal/apiservice/data"
apiservice_power "powerswitch/internal/apiservice/power"
apiservice_printer "powerswitch/internal/apiservice/printer"
apiservice_relay "powerswitch/internal/apiservice/relay"
host "periph.io/x/host/v3"
)
var (
logger log.Logger = *log.Default()
)
func init() {
logger.SetFlags(log.Llongfile | log.Ltime)
logger.Println("Starting")
}
func main() {
var webui_path string
flag.StringVar(&webui_path, "w", "../webui", "Specify path to serve the web ui. Default is ../webui")
flag.Parse()
host.Init()
apiservice_camera.AddHandler()
apiservice_data.AddHandler()
apiservice_power.AddHandler()
apiservice_printer.AddHandler()
apiservice_relay.AddHandler()
port := ":80"
http.Handle("/", http.FileServer(http.Dir(webui_path)))
logger.Fatal(http.ListenAndServe(port, nil))
}