photoprism/internal/server/server.go

27 lines
569 B
Go
Raw Normal View History

package server
import (
"fmt"
2018-09-06 14:47:32 +02:00
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/photoprism"
)
2018-11-06 19:02:03 +01:00
// 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()))
}