2018-07-20 14:13:52 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 07:14:33 +01:00
|
|
|
|
2018-09-06 14:47:32 +02:00
|
|
|
"github.com/gin-gonic/gin"
|
2018-09-14 14:04:03 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
2018-07-20 14:13:52 +02:00
|
|
|
)
|
|
|
|
|
2018-11-06 19:02:03 +01:00
|
|
|
// Start the REST API server using the configuration provided
|
2018-11-17 06:21:39 +01:00
|
|
|
func Start(conf photoprism.Config) {
|
2018-12-21 03:18:01 +01:00
|
|
|
if conf.HttpServerMode() != "" {
|
|
|
|
gin.SetMode(conf.HttpServerMode())
|
2018-12-21 02:49:45 +01:00
|
|
|
} else if conf.Debug() == false {
|
2018-09-13 11:34:56 +02:00
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
}
|
|
|
|
|
2018-09-13 07:05:13 +02:00
|
|
|
app := gin.Default()
|
2018-07-20 14:13:52 +02:00
|
|
|
|
2018-09-24 11:27:46 +02:00
|
|
|
// Set template directory
|
2018-12-21 03:44:38 +01:00
|
|
|
app.LoadHTMLGlob(conf.HttpTemplatesPath() + "/*")
|
2018-09-24 11:27:46 +02:00
|
|
|
|
|
|
|
registerRoutes(app, conf)
|
2018-07-20 14:13:52 +02:00
|
|
|
|
2018-12-21 03:16:50 +01:00
|
|
|
app.Run(fmt.Sprintf("%s:%d", conf.HttpServerHost(), conf.HttpServerPort()))
|
2018-09-27 08:59:53 +02:00
|
|
|
}
|