photoprism/internal/server/server.go
2018-12-21 03:44:38 +01:00

26 lines
569 B
Go

package server
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/photoprism"
)
// Start the REST API server using the configuration provided
func Start(conf photoprism.Config) {
if conf.HttpServerMode() != "" {
gin.SetMode(conf.HttpServerMode())
} else if conf.Debug() == false {
gin.SetMode(gin.ReleaseMode)
}
app := gin.Default()
// Set template directory
app.LoadHTMLGlob(conf.HttpTemplatesPath() + "/*")
registerRoutes(app, conf)
app.Run(fmt.Sprintf("%s:%d", conf.HttpServerHost(), conf.HttpServerPort()))
}