Simple MJPEG streamer for ESPHome cameras.
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.

33 lines
817 B

1 year ago
  1. package main
  2. import (
  3. "flag"
  4. "github.com/sirupsen/logrus"
  5. )
  6. var log = logrus.New()
  7. func main() {
  8. var (
  9. config = DefaultConfig()
  10. configPathFlag = flag.String("config", "", "configuration path")
  11. )
  12. flag.StringVar(&config.Listen, "listen", config.Listen, "server listen address")
  13. flag.StringVar(&config.Static, "static", config.Static, "static files path")
  14. flag.StringVar(&config.Template, "template", config.Template, "template files path")
  15. flag.Parse()
  16. if *configPathFlag != "" {
  17. if err := config.Load(*configPathFlag); err != nil {
  18. log.WithField("config", *configPathFlag).Fatalln("error reading configuration")
  19. }
  20. }
  21. s, err := NewServer(config)
  22. if err != nil {
  23. log.Fatalln(err)
  24. }
  25. log.Println("server: starting on http://" + config.Listen)
  26. log.Fatalln(s.Start(config.Listen))
  27. }